| Copyright | (c) The University of Glasgow 2001 |
|---|---|
| License | BSD-style (see the file libraries/base/LICENSE) |
| Maintainer | libraries@haskell.org |
| Stability | stable |
| Portability | portable |
| Safe Haskell | Trustworthy |
| Language | Haskell2010 |
The Prelude: a standard module. The Prelude is imported by default into all Haskell modules unless either there is an explicit import statement for it, or the NoImplicitPrelude extension is enabled.
| Data Bool Source | Since: base-4.0.0.0 |
Defined in Data.Data Methodsgfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Bool -> c Bool Source gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Bool Source toConstr :: Bool -> Constr Source dataTypeOf :: Bool -> DataType Source dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Bool) Source dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Bool) Source gmapT :: (forall b. Data b => b -> b) -> Bool -> Bool Source gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Bool -> r Source gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Bool -> r Source gmapQ :: (forall d. Data d => d -> u) -> Bool -> [u] Source gmapQi :: Int -> (forall d. Data d => d -> u) -> Bool -> u Source gmapM :: Monad m => (forall d. Data d => d -> m d) -> Bool -> m Bool Source gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Bool -> m Bool Source gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Bool -> m Bool Source | |
| Storable Bool Source | Since: base-2.1 |
Defined in Foreign.Storable | |
| Bits Bool Source |
Interpret Since: base-4.7.0.0 |
Defined in GHC.Bits Methods(.&.) :: Bool -> Bool -> Bool Source (.|.) :: Bool -> Bool -> Bool Source xor :: Bool -> Bool -> Bool Source complement :: Bool -> Bool Source shift :: Bool -> Int -> Bool Source rotate :: Bool -> Int -> Bool Source setBit :: Bool -> Int -> Bool Source clearBit :: Bool -> Int -> Bool Source complementBit :: Bool -> Int -> Bool Source testBit :: Bool -> Int -> Bool Source bitSizeMaybe :: Bool -> Maybe Int Source isSigned :: Bool -> Bool Source shiftL :: Bool -> Int -> Bool Source unsafeShiftL :: Bool -> Int -> Bool Source shiftR :: Bool -> Int -> Bool Source unsafeShiftR :: Bool -> Int -> Bool Source rotateL :: Bool -> Int -> Bool Source | |
| FiniteBits Bool Source | Since: base-4.7.0.0 |
Defined in GHC.Bits MethodsfiniteBitSize :: Bool -> Int Source countLeadingZeros :: Bool -> Int Source countTrailingZeros :: Bool -> Int Source | |
| Bounded Bool Source | Since: base-2.1 |
| Enum Bool Source | Since: base-2.1 |
| Generic Bool Source | |
| Ix Bool Source | Since: base-2.1 |
| Read Bool Source | Since: base-2.1 |
| Show Bool Source | Since: base-2.1 |
| Eq Bool | |
| Ord Bool | |
| type Rep Bool Source | Since: base-4.6.0.0 |
(&&) :: Bool -> Bool -> Bool infixr 3 Source
Boolean "and", lazy in the second argument
(||) :: Bool -> Bool -> Bool infixr 2 Source
Boolean "or", lazy in the second argument
Boolean "not"
otherwise is defined as the value True. It helps to make guards more readable. eg.
f x | x < 0 = ...
| otherwise = ...
The Maybe type encapsulates an optional value. A value of type Maybe a either contains a value of type a (represented as Just a), or it is empty (represented as Nothing). Using Maybe is a good way to deal with errors or exceptional cases without resorting to drastic measures such as error.
The Maybe type is also a monad. It is a simple kind of error monad, where all errors are represented by Nothing. A richer error monad can be built using the Either type.
| MonadFail Maybe Source | Since: base-4.9.0.0 |
Defined in Control.Monad.Fail | |
| MonadFix Maybe Source | Since: base-2.1 |
Defined in Control.Monad.Fix | |
| MonadZip Maybe Source | Since: base-4.8.0.0 |
| Foldable Maybe Source | Since: base-2.1 |
Defined in Data.Foldable Methodsfold :: Monoid m => Maybe m -> m Source foldMap :: Monoid m => (a -> m) -> Maybe a -> m Source foldMap' :: Monoid m => (a -> m) -> Maybe a -> m Source foldr :: (a -> b -> b) -> b -> Maybe a -> b Source foldr' :: (a -> b -> b) -> b -> Maybe a -> b Source foldl :: (b -> a -> b) -> b -> Maybe a -> b Source foldl' :: (b -> a -> b) -> b -> Maybe a -> b Source foldr1 :: (a -> a -> a) -> Maybe a -> a Source foldl1 :: (a -> a -> a) -> Maybe a -> a Source toList :: Maybe a -> [a] Source null :: Maybe a -> Bool Source length :: Maybe a -> Int Source elem :: Eq a => a -> Maybe a -> Bool Source maximum :: Ord a => Maybe a -> a Source minimum :: Ord a => Maybe a -> a Source | |
| Eq1 Maybe Source | Since: base-4.9.0.0 |
| Ord1 Maybe Source | Since: base-4.9.0.0 |
Defined in Data.Functor.Classes | |
| Read1 Maybe Source | Since: base-4.9.0.0 |
Defined in Data.Functor.Classes MethodsliftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (Maybe a) Source liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [Maybe a] Source liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (Maybe a) Source liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [Maybe a] Source | |
| Show1 Maybe Source | Since: base-4.9.0.0 |
| Traversable Maybe Source | Since: base-2.1 |
| Alternative Maybe Source | Since: base-2.1 |
| Applicative Maybe Source | Since: base-2.1 |
| Functor Maybe Source | Since: base-2.1 |
| Monad Maybe Source | Since: base-2.1 |
| MonadPlus Maybe Source | Since: base-2.1 |
| Generic1 Maybe Source | |
| Data a => Data (Maybe a) Source | Since: base-4.0.0.0 |
Defined in Data.Data Methodsgfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Maybe a -> c (Maybe a) Source gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Maybe a) Source toConstr :: Maybe a -> Constr Source dataTypeOf :: Maybe a -> DataType Source dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Maybe a)) Source dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Maybe a)) Source gmapT :: (forall b. Data b => b -> b) -> Maybe a -> Maybe a Source gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Maybe a -> r Source gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Maybe a -> r Source gmapQ :: (forall d. Data d => d -> u) -> Maybe a -> [u] Source gmapQi :: Int -> (forall d. Data d => d -> u) -> Maybe a -> u Source gmapM :: Monad m => (forall d. Data d => d -> m d) -> Maybe a -> m (Maybe a) Source gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Maybe a -> m (Maybe a) Source gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Maybe a -> m (Maybe a) Source | |
| Semigroup a => Monoid (Maybe a) Source |
Lift a semigroup into Since 4.11.0: constraint on inner Since: base-2.1 |
| Semigroup a => Semigroup (Maybe a) Source | Since: base-4.9.0.0 |
| Generic (Maybe a) Source | |
| Read a => Read (Maybe a) Source | Since: base-2.1 |
| Show a => Show (Maybe a) Source | Since: base-2.1 |
| Eq a => Eq (Maybe a) Source | Since: base-2.1 |
| Ord a => Ord (Maybe a) Source | Since: base-2.1 |
| type Rep1 Maybe Source | Since: base-4.6.0.0 |
| type Rep (Maybe a) Source | Since: base-4.6.0.0 |
Defined in GHC.Generics | |
maybe :: b -> (a -> b) -> Maybe a -> b Source
The maybe function takes a default value, a function, and a Maybe value. If the Maybe value is Nothing, the function returns the default value. Otherwise, it applies the function to the value inside the Just and returns the result.
Basic usage:
>>> maybe False odd (Just 3) True
>>> maybe False odd Nothing False
Read an integer from a string using readMaybe. If we succeed, return twice the integer; that is, apply (*2) to it. If instead we fail to parse an integer, return 0 by default:
>>> import Text.Read ( readMaybe ) >>> maybe 0 (*2) (readMaybe "5") 10 >>> maybe 0 (*2) (readMaybe "") 0
Apply show to a Maybe Int. If we have Just n, we want to show the underlying Int n. But if we have Nothing, we return the empty string instead of (for example) "Nothing":
>>> maybe "" show (Just 5) "5" >>> maybe "" show Nothing ""
The Either type represents values with two possibilities: a value of type Either a b is either Left a or Right b.
The Either type is sometimes used to represent a value which is either correct or an error; by convention, the Left constructor is used to hold an error value and the Right constructor is used to hold a correct value (mnemonic: "right" also means "correct").
The type Either String Int is the type of values which can be either a String or an Int. The Left constructor can be used only on Strings, and the Right constructor can be used only on Ints:
>>> let s = Left "foo" :: Either String Int >>> s Left "foo" >>> let n = Right 3 :: Either String Int >>> n Right 3 >>> :type s s :: Either String Int >>> :type n n :: Either String Int
The fmap from our Functor instance will ignore Left values, but will apply the supplied function to values contained in a Right:
>>> let s = Left "foo" :: Either String Int >>> let n = Right 3 :: Either String Int >>> fmap (*2) s Left "foo" >>> fmap (*2) n Right 6
The Monad instance for Either allows us to chain together multiple actions which may fail, and fail overall if any of the individual steps failed. First we'll write a function that can either parse an Int from a Char, or fail.
>>> import Data.Char ( digitToInt, isDigit )
>>> :{
let parseEither :: Char -> Either String Int
parseEither c
| isDigit c = Right (digitToInt c)
| otherwise = Left "parse error"
>>> :}
The following should work, since both '1' and '2' can be parsed as Ints.
>>> :{
let parseMultiple :: Either String Int
parseMultiple = do
x <- parseEither '1'
y <- parseEither '2'
return (x + y)
>>> :}
>>> parseMultiple Right 3
But the following should fail overall, since the first operation where we attempt to parse 'm' as an Int will fail:
>>> :{
let parseMultiple :: Either String Int
parseMultiple = do
x <- parseEither 'm'
y <- parseEither '2'
return (x + y)
>>> :}
>>> parseMultiple Left "parse error"
| Bifoldable Either Source | Since: base-4.10.0.0 |
| Bifunctor Either Source | Since: base-4.8.0.0 |
| Bitraversable Either Source | Since: base-4.10.0.0 |
Defined in Data.Bitraversable Methodsbitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> Either a b -> f (Either c d) Source | |
| Eq2 Either Source | Since: base-4.9.0.0 |
| Ord2 Either Source | Since: base-4.9.0.0 |
Defined in Data.Functor.Classes | |
| Read2 Either Source | Since: base-4.9.0.0 |
Defined in Data.Functor.Classes MethodsliftReadsPrec2 :: (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> Int -> ReadS (Either a b) Source liftReadList2 :: (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> ReadS [Either a b] Source liftReadPrec2 :: ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec (Either a b) Source liftReadListPrec2 :: ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec [Either a b] Source | |
| Show2 Either Source | Since: base-4.9.0.0 |
Defined in Data.Functor.Classes | |
| Generic1 (Either a :: Type -> Type) Source | |
| MonadFix (Either e) Source | Since: base-4.3.0.0 |
Defined in Control.Monad.Fix | |
| Foldable (Either a) Source | Since: base-4.7.0.0 |
Defined in Data.Foldable Methodsfold :: Monoid m => Either a m -> m Source foldMap :: Monoid m => (a0 -> m) -> Either a a0 -> m Source foldMap' :: Monoid m => (a0 -> m) -> Either a a0 -> m Source foldr :: (a0 -> b -> b) -> b -> Either a a0 -> b Source foldr' :: (a0 -> b -> b) -> b -> Either a a0 -> b Source foldl :: (b -> a0 -> b) -> b -> Either a a0 -> b Source foldl' :: (b -> a0 -> b) -> b -> Either a a0 -> b Source foldr1 :: (a0 -> a0 -> a0) -> Either a a0 -> a0 Source foldl1 :: (a0 -> a0 -> a0) -> Either a a0 -> a0 Source toList :: Either a a0 -> [a0] Source null :: Either a a0 -> Bool Source length :: Either a a0 -> Int Source elem :: Eq a0 => a0 -> Either a a0 -> Bool Source maximum :: Ord a0 => Either a a0 -> a0 Source minimum :: Ord a0 => Either a a0 -> a0 Source | |
| Eq a => Eq1 (Either a) Source | Since: base-4.9.0.0 |
| Ord a => Ord1 (Either a) Source | Since: base-4.9.0.0 |
Defined in Data.Functor.Classes | |
| Read a => Read1 (Either a) Source | Since: base-4.9.0.0 |
Defined in Data.Functor.Classes MethodsliftReadsPrec :: (Int -> ReadS a0) -> ReadS [a0] -> Int -> ReadS (Either a a0) Source liftReadList :: (Int -> ReadS a0) -> ReadS [a0] -> ReadS [Either a a0] Source liftReadPrec :: ReadPrec a0 -> ReadPrec [a0] -> ReadPrec (Either a a0) Source liftReadListPrec :: ReadPrec a0 -> ReadPrec [a0] -> ReadPrec [Either a a0] Source | |
| Show a => Show1 (Either a) Source | Since: base-4.9.0.0 |
| Traversable (Either a) Source | Since: base-4.7.0.0 |
Defined in Data.Traversable | |
| Applicative (Either e) Source | Since: base-3.0 |
Defined in Data.Either | |
| Functor (Either a) Source | Since: base-3.0 |
| Monad (Either e) Source | Since: base-4.4.0.0 |
| (Data a, Data b) => Data (Either a b) Source | Since: base-4.0.0.0 |
Defined in Data.Data Methodsgfoldl :: (forall d b0. Data d => c (d -> b0) -> d -> c b0) -> (forall g. g -> c g) -> Either a b -> c (Either a b) Source gunfold :: (forall b0 r. Data b0 => c (b0 -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Either a b) Source toConstr :: Either a b -> Constr Source dataTypeOf :: Either a b -> DataType Source dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Either a b)) Source dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Either a b)) Source gmapT :: (forall b0. Data b0 => b0 -> b0) -> Either a b -> Either a b Source gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Either a b -> r Source gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Either a b -> r Source gmapQ :: (forall d. Data d => d -> u) -> Either a b -> [u] Source gmapQi :: Int -> (forall d. Data d => d -> u) -> Either a b -> u Source gmapM :: Monad m => (forall d. Data d => d -> m d) -> Either a b -> m (Either a b) Source gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Either a b -> m (Either a b) Source gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Either a b -> m (Either a b) Source | |
| Semigroup (Either a b) Source | Since: base-4.9.0.0 |
| Generic (Either a b) Source | |
| (Read a, Read b) => Read (Either a b) Source | Since: base-3.0 |
| (Show a, Show b) => Show (Either a b) Source | Since: base-3.0 |
| (Eq a, Eq b) => Eq (Either a b) Source | Since: base-2.1 |
| (Ord a, Ord b) => Ord (Either a b) Source | Since: base-2.1 |
Defined in Data.Either Methodscompare :: Either a b -> Either a b -> Ordering Source (<) :: Either a b -> Either a b -> Bool Source (<=) :: Either a b -> Either a b -> Bool Source (>) :: Either a b -> Either a b -> Bool Source (>=) :: Either a b -> Either a b -> Bool Source | |
| type Rep1 (Either a :: Type -> Type) Source | Since: base-4.6.0.0 |
Defined in GHC.Generics type Rep1 (Either a :: Type -> Type) = D1 ('MetaData "Either" "Data.Either" "base" 'False) (C1 ('MetaCons "Left" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)) :+: C1 ('MetaCons "Right" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1)) | |
| type Rep (Either a b) Source | Since: base-4.6.0.0 |
Defined in GHC.Generics type Rep (Either a b) = D1 ('MetaData "Either" "Data.Either" "base" 'False) (C1 ('MetaCons "Left" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)) :+: C1 ('MetaCons "Right" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 b))) | |
either :: (a -> c) -> (b -> c) -> Either a b -> c Source
Case analysis for the Either type. If the value is Left a, apply the first function to a; if it is Right b, apply the second function to b.
We create two values of type Either String Int, one using the Left constructor and another using the Right constructor. Then we apply "either" the length function (if we have a String) or the "times-two" function (if we have an Int):
>>> let s = Left "foo" :: Either String Int >>> let n = Right 3 :: Either String Int >>> either length (*2) s 3 >>> either length (*2) n 6
The character type Char is an enumeration whose values represent Unicode (or equivalently ISO/IEC 10646) code points (i.e. characters, see http://www.unicode.org/ for details). This set extends the ISO 8859-1 (Latin-1) character set (the first 256 characters), which is itself an extension of the ASCII character set (the first 128 characters). A character literal in Haskell has type Char.
To convert a Char to or from the corresponding Int value defined by Unicode, use toEnum and fromEnum from the Enum class respectively (or equivalently ord and chr).
| Data Char Source | Since: base-4.0.0.0 |
Defined in Data.Data Methodsgfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Char -> c Char Source gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Char Source toConstr :: Char -> Constr Source dataTypeOf :: Char -> DataType Source dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Char) Source dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Char) Source gmapT :: (forall b. Data b => b -> b) -> Char -> Char Source gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Char -> r Source gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Char -> r Source gmapQ :: (forall d. Data d => d -> u) -> Char -> [u] Source gmapQi :: Int -> (forall d. Data d => d -> u) -> Char -> u Source gmapM :: Monad m => (forall d. Data d => d -> m d) -> Char -> m Char Source gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Char -> m Char Source gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Char -> m Char Source | |
| Storable Char Source | Since: base-2.1 |
Defined in Foreign.Storable | |
| Bounded Char Source | Since: base-2.1 |
| Enum Char Source | Since: base-2.1 |
| Ix Char Source | Since: base-2.1 |
| Read Char Source | Since: base-2.1 |
| Show Char Source | Since: base-2.1 |
| IsChar Char Source | Since: base-2.1 |
| PrintfArg Char Source | Since: base-2.1 |
Defined in Text.Printf | |
| Eq Char | |
| Ord Char | |
| Generic1 (URec Char :: k -> Type) Source | |
| Foldable (UChar :: Type -> Type) Source | Since: base-4.9.0.0 |
Defined in Data.Foldable Methodsfold :: Monoid m => UChar m -> m Source foldMap :: Monoid m => (a -> m) -> UChar a -> m Source foldMap' :: Monoid m => (a -> m) -> UChar a -> m Source foldr :: (a -> b -> b) -> b -> UChar a -> b Source foldr' :: (a -> b -> b) -> b -> UChar a -> b Source foldl :: (b -> a -> b) -> b -> UChar a -> b Source foldl' :: (b -> a -> b) -> b -> UChar a -> b Source foldr1 :: (a -> a -> a) -> UChar a -> a Source foldl1 :: (a -> a -> a) -> UChar a -> a Source toList :: UChar a -> [a] Source null :: UChar a -> Bool Source length :: UChar a -> Int Source elem :: Eq a => a -> UChar a -> Bool Source maximum :: Ord a => UChar a -> a Source minimum :: Ord a => UChar a -> a Source | |
| Traversable (UChar :: Type -> Type) Source | Since: base-4.9.0.0 |
| Functor (URec Char :: Type -> Type) Source | Since: base-4.9.0.0 |
| Generic (URec Char p) Source | |
| Show (URec Char p) Source | Since: base-4.9.0.0 |
| Eq (URec Char p) Source | Since: base-4.9.0.0 |
| Ord (URec Char p) Source | Since: base-4.9.0.0 |
Defined in GHC.Generics Methodscompare :: URec Char p -> URec Char p -> Ordering Source (<) :: URec Char p -> URec Char p -> Bool Source (<=) :: URec Char p -> URec Char p -> Bool Source (>) :: URec Char p -> URec Char p -> Bool Source (>=) :: URec Char p -> URec Char p -> Bool Source | |
| data URec Char (p :: k) Source |
Used for marking occurrences of Since: base-4.9.0.0 |
| type Compare (a :: Char) (b :: Char) Source | |
Defined in Data.Type.Ord | |
| type Rep1 (URec Char :: k -> Type) Source | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
| type Rep (URec Char p) Source | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
A String is a list of characters. String constants in Haskell are values of type String.
See Data.List for operations on lists.
Extract the first component of a pair.
Extract the second component of a pair.
curry :: ((a, b) -> c) -> a -> b -> c Source
curry converts an uncurried function to a curried function.
>>> curry fst 1 2 1
uncurry :: (a -> b -> c) -> (a, b) -> c Source
uncurry converts a curried function to a function on pairs.
>>> uncurry (+) (1,2) 3
>>> uncurry ($) (show, 1) "1"
>>> map (uncurry max) [(1,2), (3,4), (6,8)] [2,4,8]
The Eq class defines equality (==) and inequality (/=). All the basic datatypes exported by the Prelude are instances of Eq, and Eq may be derived for any datatype whose constituents are also instances of Eq.
The Haskell Report defines no laws for Eq. However, instances are encouraged to follow these properties:
x == x = True
x == y = y == x
x == y && y == z = True, then x == z = True
x == y = True and f is a function whose return type is an instance of Eq, then f x == f y = True
x /= y = not (x == y)
Minimal complete definition: either == or /=.
| Eq ByteArray Source | Since: base-4.17.0.0 |
| Eq Constr Source |
Equality of constructors Since: base-4.0.0.0 |
| Eq ConstrRep Source | Since: base-4.0.0.0 |
| Eq DataRep Source | Since: base-4.0.0.0 |
| Eq Fixity Source | Since: base-4.0.0.0 |
| Eq All Source | Since: base-2.1 |
| Eq Any Source | Since: base-2.1 |
| Eq SomeTypeRep Source | |
Defined in Data.Typeable.Internal Methods(==) :: SomeTypeRep -> SomeTypeRep -> Bool Source (/=) :: SomeTypeRep -> SomeTypeRep -> Bool Source | |
| Eq Unique Source | |
| Eq Version Source | Since: base-2.1 |
| Eq Void Source | Since: base-4.8.0.0 |
| Eq Errno Source | Since: base-2.1 |
| Eq CBool Source | |
| Eq CChar Source | |
| Eq CClock Source | |
| Eq CDouble Source | |
| Eq CFloat Source | |
| Eq CInt Source | |
| Eq CIntMax Source | |
| Eq CIntPtr Source | |
| Eq CLLong Source | |
| Eq CLong Source | |
| Eq CPtrdiff Source | |
| Eq CSChar Source | |
| Eq CSUSeconds Source | |
Defined in Foreign.C.Types Methods(==) :: CSUSeconds -> CSUSeconds -> Bool Source (/=) :: CSUSeconds -> CSUSeconds -> Bool Source | |
| Eq CShort Source | |
| Eq CSigAtomic Source | |
Defined in Foreign.C.Types Methods(==) :: CSigAtomic -> CSigAtomic -> Bool Source (/=) :: CSigAtomic -> CSigAtomic -> Bool Source | |
| Eq CSize Source | |
| Eq CTime Source | |
| Eq CUChar Source | |
| Eq CUInt Source | |
| Eq CUIntMax Source | |
| Eq CUIntPtr Source | |
| Eq CULLong Source | |
| Eq CULong Source | |
| Eq CUSeconds Source | |
| Eq CUShort Source | |
| Eq CWchar Source | |
| Eq IntPtr Source | |
| Eq WordPtr Source | |
| Eq ByteOrder Source | Since: base-4.11.0.0 |
| Eq BlockReason Source | Since: base-4.3.0.0 |
Defined in GHC.Conc.Sync Methods(==) :: BlockReason -> BlockReason -> Bool Source (/=) :: BlockReason -> BlockReason -> Bool Source | |
| Eq ThreadId Source | Since: base-4.2.0.0 |
| Eq ThreadStatus Source | Since: base-4.3.0.0 |
Defined in GHC.Conc.Sync Methods(==) :: ThreadStatus -> ThreadStatus -> Bool Source (/=) :: ThreadStatus -> ThreadStatus -> Bool Source | |
| Eq Event Source | Since: base-4.4.0.0 |
| Eq Lifetime Source | Since: base-4.8.1.0 |
| Eq FdKey Source | Since: base-4.4.0.0 |
| Eq TimeoutKey Source | |
Defined in GHC.Event.TimeOut Methods(==) :: TimeoutKey -> TimeoutKey -> Bool Source (/=) :: TimeoutKey -> TimeoutKey -> Bool Source | |
| Eq ErrorCall Source | Since: base-4.7.0.0 |
| Eq ArithException Source | Since: base-3.0 |
Defined in GHC.Exception.Type Methods(==) :: ArithException -> ArithException -> Bool Source (/=) :: ArithException -> ArithException -> Bool Source | |
| Eq SpecConstrAnnotation Source | Since: base-4.3.0.0 |
Defined in GHC.Exts Methods(==) :: SpecConstrAnnotation -> SpecConstrAnnotation -> Bool Source (/=) :: SpecConstrAnnotation -> SpecConstrAnnotation -> Bool Source | |
| Eq Fingerprint Source | Since: base-4.4.0.0 |
Defined in GHC.Fingerprint.Type Methods(==) :: Fingerprint -> Fingerprint -> Bool Source (/=) :: Fingerprint -> Fingerprint -> Bool Source | |
| Eq Associativity Source | Since: base-4.6.0.0 |
Defined in GHC.Generics Methods(==) :: Associativity -> Associativity -> Bool Source (/=) :: Associativity -> Associativity -> Bool Source | |
| Eq DecidedStrictness Source | Since: base-4.9.0.0 |
Defined in GHC.Generics Methods(==) :: DecidedStrictness -> DecidedStrictness -> Bool Source (/=) :: DecidedStrictness -> DecidedStrictness -> Bool Source | |
| Eq Fixity Source | Since: base-4.6.0.0 |
| Eq SourceStrictness Source | Since: base-4.9.0.0 |
Defined in GHC.Generics Methods(==) :: SourceStrictness -> SourceStrictness -> Bool Source (/=) :: SourceStrictness -> SourceStrictness -> Bool Source | |
| Eq SourceUnpackedness Source | Since: base-4.9.0.0 |
Defined in GHC.Generics Methods(==) :: SourceUnpackedness -> SourceUnpackedness -> Bool Source (/=) :: SourceUnpackedness -> SourceUnpackedness -> Bool Source | |
| Eq MaskingState Source | Since: base-4.3.0.0 |
Defined in GHC.IO Methods(==) :: MaskingState -> MaskingState -> Bool Source (/=) :: MaskingState -> MaskingState -> Bool Source | |
| Eq BufferState Source | Since: base-4.2.0.0 |
Defined in GHC.IO.Buffer Methods(==) :: BufferState -> BufferState -> Bool Source (/=) :: BufferState -> BufferState -> Bool Source | |
| Eq IODeviceType Source | Since: base-4.2.0.0 |
Defined in GHC.IO.Device Methods(==) :: IODeviceType -> IODeviceType -> Bool Source (/=) :: IODeviceType -> IODeviceType -> Bool Source | |
| Eq SeekMode Source | Since: base-4.2.0.0 |
| Eq CodingProgress Source | Since: base-4.4.0.0 |
Defined in GHC.IO.Encoding.Types Methods(==) :: CodingProgress -> CodingProgress -> Bool Source (/=) :: CodingProgress -> CodingProgress -> Bool Source | |
| Eq ArrayException Source | Since: base-4.2.0.0 |
Defined in GHC.IO.Exception Methods(==) :: ArrayException -> ArrayException -> Bool Source (/=) :: ArrayException -> ArrayException -> Bool Source | |
| Eq AsyncException Source | Since: base-4.2.0.0 |
Defined in GHC.IO.Exception Methods(==) :: AsyncException -> AsyncException -> Bool Source (/=) :: AsyncException -> AsyncException -> Bool Source | |
| Eq ExitCode Source | |
| Eq IOErrorType Source | Since: base-4.1.0.0 |
Defined in GHC.IO.Exception Methods(==) :: IOErrorType -> IOErrorType -> Bool Source (/=) :: IOErrorType -> IOErrorType -> Bool Source | |
| Eq IOException Source | Since: base-4.1.0.0 |
Defined in GHC.IO.Exception Methods(==) :: IOException -> IOException -> Bool Source (/=) :: IOException -> IOException -> Bool Source | |
| Eq HandlePosn Source | Since: base-4.1.0.0 |
Defined in GHC.IO.Handle Methods(==) :: HandlePosn -> HandlePosn -> Bool Source (/=) :: HandlePosn -> HandlePosn -> Bool Source | |
| Eq BufferMode Source | Since: base-4.2.0.0 |
Defined in GHC.IO.Handle.Types Methods(==) :: BufferMode -> BufferMode -> Bool Source (/=) :: BufferMode -> BufferMode -> Bool Source | |
| Eq Handle Source | Since: base-4.1.0.0 |
| Eq Newline Source | Since: base-4.2.0.0 |
| Eq NewlineMode Source | Since: base-4.2.0.0 |
Defined in GHC.IO.Handle.Types Methods(==) :: NewlineMode -> NewlineMode -> Bool Source (/=) :: NewlineMode -> NewlineMode -> Bool Source | |
| Eq IOMode Source | Since: base-4.2.0.0 |
| Eq Int16 Source | Since: base-2.1 |
| Eq Int32 Source | Since: base-2.1 |
| Eq Int64 Source | Since: base-2.1 |
| Eq Int8 Source | Since: base-2.1 |
| Eq IoSubSystem Source | |
Defined in GHC.RTS.Flags Methods(==) :: IoSubSystem -> IoSubSystem -> Bool Source (/=) :: IoSubSystem -> IoSubSystem -> Bool Source | |
| Eq InfoProv Source | |
| Eq StackEntry Source | |
Defined in GHC.Stack.CloneStack Methods(==) :: StackEntry -> StackEntry -> Bool Source (/=) :: StackEntry -> StackEntry -> Bool Source | |
| Eq SrcLoc Source | Since: base-4.9.0.0 |
| Eq SomeChar Source | |
| Eq SomeSymbol Source | Since: base-4.7.0.0 |
Defined in GHC.TypeLits Methods(==) :: SomeSymbol -> SomeSymbol -> Bool Source (/=) :: SomeSymbol -> SomeSymbol -> Bool Source | |
| Eq SomeNat Source | Since: base-4.7.0.0 |
| Eq GeneralCategory Source | Since: base-2.1 |
Defined in GHC.Unicode Methods(==) :: GeneralCategory -> GeneralCategory -> Bool Source (/=) :: GeneralCategory -> GeneralCategory -> Bool Source | |
| Eq Word16 Source | Since: base-2.1 |
| Eq Word32 Source | Since: base-2.1 |
| Eq Word64 Source | Since: base-2.1 |
| Eq Word8 Source | Since: base-2.1 |
| Eq CBlkCnt Source | |
| Eq CBlkSize Source | |
| Eq CCc Source | |
| Eq CClockId Source | |
| Eq CDev Source | |
| Eq CFsBlkCnt Source | |
| Eq CFsFilCnt Source | |
| Eq CGid Source | |
| Eq CId Source | |
| Eq CIno Source | |
| Eq CKey Source | |
| Eq CMode Source | |
| Eq CNfds Source | |
| Eq CNlink Source | |
| Eq COff Source | |
| Eq CPid Source | |
| Eq CRLim Source | |
| Eq CSocklen Source | |
| Eq CSpeed Source | |
| Eq CSsize Source | |
| Eq CTcflag Source | |
| Eq CTimer Source | |
| Eq CUid Source | |
| Eq Fd Source | |
| Eq Timeout Source | |
| Eq Lexeme Source | Since: base-2.1 |
| Eq Number Source | Since: base-4.6.0.0 |
| Eq BigNat | |
| Eq Module | |
| Eq Ordering | |
| Eq TrName | |
| Eq TyCon | |
| Eq Integer | |
| Eq Natural | |
| Eq () | |
| Eq Bool | |
| Eq Char | |
| Eq Double |
Note that due to the presence of >>> 0/0 == (0/0 :: Double) False Also note that >>> 0 == (-0 :: Double) True >>> recip 0 == recip (-0 :: Double) False |
| Eq Float |
Note that due to the presence of >>> 0/0 == (0/0 :: Float) False Also note that >>> 0 == (-0 :: Float) True >>> recip 0 == recip (-0 :: Float) False |
| Eq Int | |
| Eq Word | |
| Eq a => Eq (ZipList a) Source | Since: base-4.7.0.0 |
| Eq (Chan a) Source | Since: base-4.4.0.0 |
| Eq (MutableByteArray s) Source | Since: base-4.17.0.0 |
Defined in Data.Array.Byte Methods(==) :: MutableByteArray s -> MutableByteArray s -> Bool Source (/=) :: MutableByteArray s -> MutableByteArray s -> Bool Source | |
| Eq a => Eq (And a) Source | Since: base-4.16 |
| Eq a => Eq (Iff a) Source | Since: base-4.16 |
| Eq a => Eq (Ior a) Source | Since: base-4.16 |
| Eq a => Eq (Xor a) Source | Since: base-4.16 |
| Eq a => Eq (Complex a) Source | Since: base-2.1 |
| Eq a => Eq (Identity a) Source | Since: base-4.8.0.0 |
| Eq a => Eq (First a) Source | Since: base-2.1 |
| Eq a => Eq (Last a) Source | Since: base-2.1 |
| Eq a => Eq (Down a) Source | Since: base-4.6.0.0 |
| Eq a => Eq (First a) Source | Since: base-4.9.0.0 |
| Eq a => Eq (Last a) Source | Since: base-4.9.0.0 |
| Eq a => Eq (Max a) Source | Since: base-4.9.0.0 |
| Eq a => Eq (Min a) Source | Since: base-4.9.0.0 |
| Eq m => Eq (WrappedMonoid m) Source | Since: base-4.9.0.0 |
Defined in Data.Semigroup Methods(==) :: WrappedMonoid m -> WrappedMonoid m -> Bool Source (/=) :: WrappedMonoid m -> WrappedMonoid m -> Bool Source | |
| Eq a => Eq (Dual a) Source | Since: base-2.1 |
| Eq a => Eq (Product a) Source | Since: base-2.1 |
| Eq a => Eq (Sum a) Source | Since: base-2.1 |
| Eq (TVar a) Source | Since: base-4.8.0.0 |
| Eq (ForeignPtr a) Source | Since: base-2.1 |
Defined in GHC.ForeignPtr Methods(==) :: ForeignPtr a -> ForeignPtr a -> Bool Source (/=) :: ForeignPtr a -> ForeignPtr a -> Bool Source | |
| Eq p => Eq (Par1 p) Source | Since: base-4.7.0.0 |
| Eq (IORef a) Source |
Pointer equality. Since: base-4.0.0.0 |
| Eq (MVar a) Source | Since: base-4.1.0.0 |
| Eq (FunPtr a) Source | |
| Eq (Ptr a) Source | Since: base-2.1 |
| Eq a => Eq (Ratio a) Source | Since: base-2.1 |
| Eq (StablePtr a) Source | Since: base-2.1 |
| Eq (StableName a) Source | Since: base-2.1 |
Defined in GHC.StableName Methods(==) :: StableName a -> StableName a -> Bool Source (/=) :: StableName a -> StableName a -> Bool Source | |
| Eq a => Eq (NonEmpty a) Source | Since: base-4.9.0.0 |
| Eq a => Eq (Maybe a) Source | Since: base-2.1 |
| Eq a => Eq (a) | |
| Eq a => Eq [a] | |
| (Eq a, Eq b) => Eq (Either a b) Source | Since: base-2.1 |
| Eq (Fixed a) Source | Since: base-2.1 |
| Eq (Proxy s) Source | Since: base-4.7.0.0 |
| Eq a => Eq (Arg a b) Source | Since: base-4.9.0.0 |
| Eq (TypeRep a) Source | Since: base-2.1 |
| (Ix i, Eq e) => Eq (Array i e) Source | Since: base-2.1 |
| Eq (U1 p) Source | Since: base-4.9.0.0 |
| Eq (V1 p) Source | Since: base-4.9.0.0 |
| Eq (IOArray i e) Source | Since: base-4.1.0.0 |
| Eq (STRef s a) Source |
Pointer equality. Since: base-2.1 |
| (Eq a, Eq b) => Eq (a, b) | |
| Eq a => Eq (Const a b) Source | Since: base-4.9.0.0 |
| Eq (f a) => Eq (Ap f a) Source | Since: base-4.12.0.0 |
| Eq (f a) => Eq (Alt f a) Source | Since: base-4.8.0.0 |
| Eq (Coercion a b) Source | Since: base-4.7.0.0 |
| Eq (a :~: b) Source | Since: base-4.7.0.0 |
| Eq (OrderingI a b) Source | |
| Eq (STArray s i e) Source | Since: base-2.1 |
| Eq (f p) => Eq (Rec1 f p) Source | Since: base-4.7.0.0 |
| Eq (URec (Ptr ()) p) Source | Since: base-4.9.0.0 |
| Eq (URec Char p) Source | Since: base-4.9.0.0 |
| Eq (URec Double p) Source | Since: base-4.9.0.0 |
| Eq (URec Float p) Source | |
| Eq (URec Int p) Source | Since: base-4.9.0.0 |
| Eq (URec Word p) Source | Since: base-4.9.0.0 |
| (Eq a, Eq b, Eq c) => Eq (a, b, c) | |
| (Eq1 f, Eq1 g, Eq a) => Eq (Product f g a) Source | Since: base-4.9.0.0 |
| (Eq1 f, Eq1 g, Eq a) => Eq (Sum f g a) Source | Since: base-4.9.0.0 |
| Eq (a :~~: b) Source | Since: base-4.10.0.0 |
| (Eq (f p), Eq (g p)) => Eq ((f :*: g) p) Source | Since: base-4.7.0.0 |
| (Eq (f p), Eq (g p)) => Eq ((f :+: g) p) Source | Since: base-4.7.0.0 |
| Eq c => Eq (K1 i c p) Source | Since: base-4.7.0.0 |
| (Eq a, Eq b, Eq c, Eq d) => Eq (a, b, c, d) | |
| (Eq1 f, Eq1 g, Eq a) => Eq (Compose f g a) Source | Since: base-4.9.0.0 |
| Eq (f (g p)) => Eq ((f :.: g) p) Source | Since: base-4.7.0.0 |
| Eq (f p) => Eq (M1 i c f p) Source | Since: base-4.7.0.0 |
| (Eq a, Eq b, Eq c, Eq d, Eq e) => Eq (a, b, c, d, e) | |
| (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f) => Eq (a, b, c, d, e, f) | |
| (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g) => Eq (a, b, c, d, e, f, g) | |
| (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h) => Eq (a, b, c, d, e, f, g, h) | |
| (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i) => Eq (a, b, c, d, e, f, g, h, i) | |
| (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j) => Eq (a, b, c, d, e, f, g, h, i, j) | |
| (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j, Eq k) => Eq (a, b, c, d, e, f, g, h, i, j, k) | |
| (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j, Eq k, Eq l) => Eq (a, b, c, d, e, f, g, h, i, j, k, l) | |
| (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j, Eq k, Eq l, Eq m) => Eq (a, b, c, d, e, f, g, h, i, j, k, l, m) | |
| (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j, Eq k, Eq l, Eq m, Eq n) => Eq (a, b, c, d, e, f, g, h, i, j, k, l, m, n) | |
| (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j, Eq k, Eq l, Eq m, Eq n, Eq o) => Eq (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) | |
class Eq a => Ord a where Source
The Ord class is used for totally ordered datatypes.
Instances of Ord can be derived for any user-defined datatype whose constituent types are in Ord. The declared order of the constructors in the data declaration determines the ordering in derived Ord instances. The Ordering datatype allows a single comparison to determine the precise ordering of two objects.
Ord, as defined by the Haskell report, implements a total order and has the following properties:
x <= y || y <= x = True
x <= y && y <= z = True, then x <= z = True
x <= x = True
x <= y && y <= x = True, then x == y = True
The following operator interactions are expected to hold:
x >= y = y <= x
x < y = x <= y && x /= y
x > y = y < x
x < y = compare x y == LT
x > y = compare x y == GT
x == y = compare x y == EQ
min x y == if x <= y then x else y = True
max x y == if x >= y then x else y = True
Note that (7.) and (8.) do not require min and max to return either of their arguments. The result is merely required to equal one of the arguments in terms of (==).
Minimal complete definition: either compare or <=. Using compare can be more efficient for complex types.
compare :: a -> a -> Ordering Source
(<) :: a -> a -> Bool infix 4 Source
(<=) :: a -> a -> Bool infix 4 Source
(>) :: a -> a -> Bool infix 4 Source
| Ord ByteArray Source | Non-lexicographic ordering. This compares the lengths of the byte arrays first and uses a lexicographic ordering if the lengths are equal. Subject to change between major versions. @since 4.17.0.0 |
Defined in Data.Array.Byte | |
| Ord All Source | Since: base-2.1 |
| Ord Any Source | Since: base-2.1 |
| Ord SomeTypeRep Source | |
Defined in Data.Typeable.Internal Methodscompare :: SomeTypeRep -> SomeTypeRep -> Ordering Source (<) :: SomeTypeRep -> SomeTypeRep -> Bool Source (<=) :: SomeTypeRep -> SomeTypeRep -> Bool Source (>) :: SomeTypeRep -> SomeTypeRep -> Bool Source (>=) :: SomeTypeRep -> SomeTypeRep -> Bool Source max :: SomeTypeRep -> SomeTypeRep -> SomeTypeRep Source min :: SomeTypeRep -> SomeTypeRep -> SomeTypeRep Source | |
| Ord Unique Source | |
Defined in Data.Unique | |
| Ord Version Source | Since: base-2.1 |
| Ord Void Source | Since: base-4.8.0.0 |
| Ord CBool Source | |
Defined in Foreign.C.Types | |
| Ord CChar Source | |
Defined in Foreign.C.Types | |
| Ord CClock Source | |
Defined in Foreign.C.Types | |
| Ord CDouble Source | |
| Ord CFloat Source | |
Defined in Foreign.C.Types | |
| Ord CInt Source | |
| Ord CIntMax Source | |
| Ord CIntPtr Source | |
| Ord CLLong Source | |
Defined in Foreign.C.Types | |
| Ord CLong Source | |
Defined in Foreign.C.Types | |
| Ord CPtrdiff Source | |
Defined in Foreign.C.Types | |
| Ord CSChar Source | |
Defined in Foreign.C.Types | |
| Ord CSUSeconds Source | |
Defined in Foreign.C.Types Methodscompare :: CSUSeconds -> CSUSeconds -> Ordering Source (<) :: CSUSeconds -> CSUSeconds -> Bool Source (<=) :: CSUSeconds -> CSUSeconds -> Bool Source (>) :: CSUSeconds -> CSUSeconds -> Bool Source (>=) :: CSUSeconds -> CSUSeconds -> Bool Source max :: CSUSeconds -> CSUSeconds -> CSUSeconds Source min :: CSUSeconds -> CSUSeconds -> CSUSeconds Source | |
| Ord CShort Source | |
Defined in Foreign.C.Types | |
| Ord CSigAtomic Source | |
Defined in Foreign.C.Types Methodscompare :: CSigAtomic -> CSigAtomic -> Ordering Source (<) :: CSigAtomic -> CSigAtomic -> Bool Source (<=) :: CSigAtomic -> CSigAtomic -> Bool Source (>) :: CSigAtomic -> CSigAtomic -> Bool Source (>=) :: CSigAtomic -> CSigAtomic -> Bool Source max :: CSigAtomic -> CSigAtomic -> CSigAtomic Source min :: CSigAtomic -> CSigAtomic -> CSigAtomic Source | |
| Ord CSize Source | |
Defined in Foreign.C.Types | |
| Ord CTime Source | |
Defined in Foreign.C.Types | |
| Ord CUChar Source | |
Defined in Foreign.C.Types | |
| Ord CUInt Source | |
Defined in Foreign.C.Types | |
| Ord CUIntMax Source | |
Defined in Foreign.C.Types | |
| Ord CUIntPtr Source | |
Defined in Foreign.C.Types | |
| Ord CULLong Source | |
| Ord CULong Source | |
Defined in Foreign.C.Types | |
| Ord CUSeconds Source | |
Defined in Foreign.C.Types | |
| Ord CUShort Source | |
| Ord CWchar Source | |
Defined in Foreign.C.Types | |
| Ord IntPtr Source | |
Defined in Foreign.Ptr | |
| Ord WordPtr Source | |
| Ord ByteOrder Source | Since: base-4.11.0.0 |
Defined in GHC.ByteOrder | |
| Ord BlockReason Source | Since: base-4.3.0.0 |
Defined in GHC.Conc.Sync Methodscompare :: BlockReason -> BlockReason -> Ordering Source (<) :: BlockReason -> BlockReason -> Bool Source (<=) :: BlockReason -> BlockReason -> Bool Source (>) :: BlockReason -> BlockReason -> Bool Source (>=) :: BlockReason -> BlockReason -> Bool Source max :: BlockReason -> BlockReason -> BlockReason Source min :: BlockReason -> BlockReason -> BlockReason Source | |
| Ord ThreadId Source | Since: base-4.2.0.0 |
Defined in GHC.Conc.Sync | |
| Ord ThreadStatus Source | Since: base-4.3.0.0 |
Defined in GHC.Conc.Sync Methodscompare :: ThreadStatus -> ThreadStatus -> Ordering Source (<) :: ThreadStatus -> ThreadStatus -> Bool Source (<=) :: ThreadStatus -> ThreadStatus -> Bool Source (>) :: ThreadStatus -> ThreadStatus -> Bool Source (>=) :: ThreadStatus -> ThreadStatus -> Bool Source max :: ThreadStatus -> ThreadStatus -> ThreadStatus Source min :: ThreadStatus -> ThreadStatus -> ThreadStatus Source | |
| Ord TimeoutKey Source | |
Defined in GHC.Event.TimeOut Methodscompare :: TimeoutKey -> TimeoutKey -> Ordering Source (<) :: TimeoutKey -> TimeoutKey -> Bool Source (<=) :: TimeoutKey -> TimeoutKey -> Bool Source (>) :: TimeoutKey -> TimeoutKey -> Bool Source (>=) :: TimeoutKey -> TimeoutKey -> Bool Source max :: TimeoutKey -> TimeoutKey -> TimeoutKey Source min :: TimeoutKey -> TimeoutKey -> TimeoutKey Source | |
| Ord ErrorCall Source | Since: base-4.7.0.0 |
Defined in GHC.Exception | |
| Ord ArithException Source | Since: base-3.0 |
Defined in GHC.Exception.Type Methodscompare :: ArithException -> ArithException -> Ordering Source (<) :: ArithException -> ArithException -> Bool Source (<=) :: ArithException -> ArithException -> Bool Source (>) :: ArithException -> ArithException -> Bool Source (>=) :: ArithException -> ArithException -> Bool Source max :: ArithException -> ArithException -> ArithException Source min :: ArithException -> ArithException -> ArithException Source | |
| Ord Fingerprint Source | Since: base-4.4.0.0 |
Defined in GHC.Fingerprint.Type Methodscompare :: Fingerprint -> Fingerprint -> Ordering Source (<) :: Fingerprint -> Fingerprint -> Bool Source (<=) :: Fingerprint -> Fingerprint -> Bool Source (>) :: Fingerprint -> Fingerprint -> Bool Source (>=) :: Fingerprint -> Fingerprint -> Bool Source max :: Fingerprint -> Fingerprint -> Fingerprint Source min :: Fingerprint -> Fingerprint -> Fingerprint Source | |
| Ord Associativity Source | Since: base-4.6.0.0 |
Defined in GHC.Generics Methodscompare :: Associativity -> Associativity -> Ordering Source (<) :: Associativity -> Associativity -> Bool Source (<=) :: Associativity -> Associativity -> Bool Source (>) :: Associativity -> Associativity -> Bool Source (>=) :: Associativity -> Associativity -> Bool Source max :: Associativity -> Associativity -> Associativity Source min :: Associativity -> Associativity -> Associativity Source | |
| Ord DecidedStrictness Source | Since: base-4.9.0.0 |
Defined in GHC.Generics Methodscompare :: DecidedStrictness -> DecidedStrictness -> Ordering Source (<) :: DecidedStrictness -> DecidedStrictness -> Bool Source (<=) :: DecidedStrictness -> DecidedStrictness -> Bool Source (>) :: DecidedStrictness -> DecidedStrictness -> Bool Source (>=) :: DecidedStrictness -> DecidedStrictness -> Bool Source max :: DecidedStrictness -> DecidedStrictness -> DecidedStrictness Source min :: DecidedStrictness -> DecidedStrictness -> DecidedStrictness Source | |
| Ord Fixity Source | Since: base-4.6.0.0 |
Defined in GHC.Generics | |
| Ord SourceStrictness Source | Since: base-4.9.0.0 |
Defined in GHC.Generics Methodscompare :: SourceStrictness -> SourceStrictness -> Ordering Source (<) :: SourceStrictness -> SourceStrictness -> Bool Source (<=) :: SourceStrictness -> SourceStrictness -> Bool Source (>) :: SourceStrictness -> SourceStrictness -> Bool Source (>=) :: SourceStrictness -> SourceStrictness -> Bool Source max :: SourceStrictness -> SourceStrictness -> SourceStrictness Source min :: SourceStrictness -> SourceStrictness -> SourceStrictness Source | |
| Ord SourceUnpackedness Source | Since: base-4.9.0.0 |
Defined in GHC.Generics Methodscompare :: SourceUnpackedness -> SourceUnpackedness -> Ordering Source (<) :: SourceUnpackedness -> SourceUnpackedness -> Bool Source (<=) :: SourceUnpackedness -> SourceUnpackedness -> Bool Source (>) :: SourceUnpackedness -> SourceUnpackedness -> Bool Source (>=) :: SourceUnpackedness -> SourceUnpackedness -> Bool Source max :: SourceUnpackedness -> SourceUnpackedness -> SourceUnpackedness Source min :: SourceUnpackedness -> SourceUnpackedness -> SourceUnpackedness Source | |
| Ord SeekMode Source | Since: base-4.2.0.0 |
Defined in GHC.IO.Device | |
| Ord ArrayException Source | Since: base-4.2.0.0 |
Defined in GHC.IO.Exception Methodscompare :: ArrayException -> ArrayException -> Ordering Source (<) :: ArrayException -> ArrayException -> Bool Source (<=) :: ArrayException -> ArrayException -> Bool Source (>) :: ArrayException -> ArrayException -> Bool Source (>=) :: ArrayException -> ArrayException -> Bool Source max :: ArrayException -> ArrayException -> ArrayException Source min :: ArrayException -> ArrayException -> ArrayException Source | |
| Ord AsyncException Source | Since: base-4.2.0.0 |
Defined in GHC.IO.Exception Methodscompare :: AsyncException -> AsyncException -> Ordering Source (<) :: AsyncException -> AsyncException -> Bool Source (<=) :: AsyncException -> AsyncException -> Bool Source (>) :: AsyncException -> AsyncException -> Bool Source (>=) :: AsyncException -> AsyncException -> Bool Source max :: AsyncException -> AsyncException -> AsyncException Source min :: AsyncException -> AsyncException -> AsyncException Source | |
| Ord ExitCode Source | |
Defined in GHC.IO.Exception | |
| Ord BufferMode Source | Since: base-4.2.0.0 |
Defined in GHC.IO.Handle.Types Methodscompare :: BufferMode -> BufferMode -> Ordering Source (<) :: BufferMode -> BufferMode -> Bool Source (<=) :: BufferMode -> BufferMode -> Bool Source (>) :: BufferMode -> BufferMode -> Bool Source (>=) :: BufferMode -> BufferMode -> Bool Source max :: BufferMode -> BufferMode -> BufferMode Source min :: BufferMode -> BufferMode -> BufferMode Source | |
| Ord Newline Source | Since: base-4.3.0.0 |
| Ord NewlineMode Source | Since: base-4.3.0.0 |
Defined in GHC.IO.Handle.Types Methodscompare :: NewlineMode -> NewlineMode -> Ordering Source (<) :: NewlineMode -> NewlineMode -> Bool Source (<=) :: NewlineMode -> NewlineMode -> Bool Source (>) :: NewlineMode -> NewlineMode -> Bool Source (>=) :: NewlineMode -> NewlineMode -> Bool Source max :: NewlineMode -> NewlineMode -> NewlineMode Source min :: NewlineMode -> NewlineMode -> NewlineMode Source | |
| Ord IOMode Source | Since: base-4.2.0.0 |
Defined in GHC.IO.IOMode | |
| Ord Int16 Source | Since: base-2.1 |
| Ord Int32 Source | Since: base-2.1 |
| Ord Int64 Source | Since: base-2.1 |
| Ord Int8 Source | Since: base-2.1 |
| Ord SomeChar Source | |
Defined in GHC.TypeLits | |
| Ord SomeSymbol Source | Since: base-4.7.0.0 |
Defined in GHC.TypeLits Methodscompare :: SomeSymbol -> SomeSymbol -> Ordering Source (<) :: SomeSymbol -> SomeSymbol -> Bool Source (<=) :: SomeSymbol -> SomeSymbol -> Bool Source (>) :: SomeSymbol -> SomeSymbol -> Bool Source (>=) :: SomeSymbol -> SomeSymbol -> Bool Source max :: SomeSymbol -> SomeSymbol -> SomeSymbol Source min :: SomeSymbol -> SomeSymbol -> SomeSymbol Source | |
| Ord SomeNat Source | Since: base-4.7.0.0 |
| Ord GeneralCategory Source | Since: base-2.1 |
Defined in GHC.Unicode Methodscompare :: GeneralCategory -> GeneralCategory -> Ordering Source (<) :: GeneralCategory -> GeneralCategory -> Bool Source (<=) :: GeneralCategory -> GeneralCategory -> Bool Source (>) :: GeneralCategory -> GeneralCategory -> Bool Source (>=) :: GeneralCategory -> GeneralCategory -> Bool Source max :: GeneralCategory -> GeneralCategory -> GeneralCategory Source min :: GeneralCategory -> GeneralCategory -> GeneralCategory Source | |
| Ord Word16 Source | Since: base-2.1 |
Defined in GHC.Word | |
| Ord Word32 Source | Since: base-2.1 |
Defined in GHC.Word | |
| Ord Word64 Source | Since: base-2.1 |
Defined in GHC.Word | |
| Ord Word8 Source | Since: base-2.1 |
| Ord CBlkCnt Source | |
| Ord CBlkSize Source | |
Defined in System.Posix.Types | |
| Ord CCc Source | |
| Ord CClockId Source | |
Defined in System.Posix.Types | |
| Ord CDev Source | |
| Ord CFsBlkCnt Source | |
Defined in System.Posix.Types | |
| Ord CFsFilCnt Source | |
Defined in System.Posix.Types | |
| Ord CGid Source | |
| Ord CId Source | |
| Ord CIno Source | |
| Ord CKey Source | |
| Ord CMode Source | |
Defined in System.Posix.Types | |
| Ord CNfds Source | |
Defined in System.Posix.Types | |
| Ord CNlink Source | |
Defined in System.Posix.Types | |
| Ord COff Source | |
| Ord CPid Source | |
| Ord CRLim Source | |
Defined in System.Posix.Types | |
| Ord CSocklen Source | |
Defined in System.Posix.Types | |
| Ord CSpeed Source | |
Defined in System.Posix.Types | |
| Ord CSsize Source | |
Defined in System.Posix.Types | |
| Ord CTcflag Source | |
| Ord CTimer Source | |
Defined in System.Posix.Types | |
| Ord CUid Source | |
| Ord Fd Source | |
| Ord BigNat | |
Defined in GHC.Num.BigNat | |
| Ord Ordering | |
Defined in GHC.Classes | |
| Ord TyCon | |
Defined in GHC.Classes | |
| Ord Integer | |
| Ord Natural | |
| Ord () | |
| Ord Bool | |
| Ord Char | |
| Ord Double |
Note that due to the presence of >>> 0/0 <= (0/0 :: Double) False Also note that, due to the same, >>> (0/0 :: Double) > 1 False >>> compare (0/0 :: Double) 1 GT |
Defined in GHC.Classes | |
| Ord Float |
Note that due to the presence of >>> 0/0 <= (0/0 :: Float) False Also note that, due to the same, >>> (0/0 :: Float) > 1 False >>> compare (0/0 :: Float) 1 GT |
Defined in GHC.Classes | |
| Ord Int | |
| Ord Word | |
| Ord a => Ord (ZipList a) Source | Since: base-4.7.0.0 |
Defined in Control.Applicative | |
| Ord a => Ord (Identity a) Source | Since: base-4.8.0.0 |
Defined in Data.Functor.Identity Methodscompare :: Identity a -> Identity a -> Ordering Source (<) :: Identity a -> Identity a -> Bool Source (<=) :: Identity a -> Identity a -> Bool Source (>) :: Identity a -> Identity a -> Bool Source (>=) :: Identity a -> Identity a -> Bool Source | |
| Ord a => Ord (First a) Source | Since: base-2.1 |
| Ord a => Ord (Last a) Source | Since: base-2.1 |
Defined in Data.Monoid | |
| Ord a => Ord (Down a) Source | Since: base-4.6.0.0 |
Defined in Data.Ord | |
| Ord a => Ord (First a) Source | Since: base-4.9.0.0 |
| Ord a => Ord (Last a) Source | Since: base-4.9.0.0 |
Defined in Data.Semigroup | |
| Ord a => Ord (Max a) Source | Since: base-4.9.0.0 |
Defined in Data.Semigroup | |
| Ord a => Ord (Min a) Source | Since: base-4.9.0.0 |
Defined in Data.Semigroup | |
| Ord m => Ord (WrappedMonoid m) Source | Since: base-4.9.0.0 |
Defined in Data.Semigroup Methodscompare :: WrappedMonoid m -> WrappedMonoid m -> Ordering Source (<) :: WrappedMonoid m -> WrappedMonoid m -> Bool Source (<=) :: WrappedMonoid m -> WrappedMonoid m -> Bool Source (>) :: WrappedMonoid m -> WrappedMonoid m -> Bool Source (>=) :: WrappedMonoid m -> WrappedMonoid m -> Bool Source max :: WrappedMonoid m -> WrappedMonoid m -> WrappedMonoid m Source min :: WrappedMonoid m -> WrappedMonoid m -> WrappedMonoid m Source | |
| Ord a => Ord (Dual a) Source | Since: base-2.1 |
Defined in Data.Semigroup.Internal | |
| Ord a => Ord (Product a) Source | Since: base-2.1 |
Defined in Data.Semigroup.Internal | |
| Ord a => Ord (Sum a) Source | Since: base-2.1 |
Defined in Data.Semigroup.Internal | |
| Ord (ForeignPtr a) Source | Since: base-2.1 |
Defined in GHC.ForeignPtr Methodscompare :: ForeignPtr a -> ForeignPtr a -> Ordering Source (<) :: ForeignPtr a -> ForeignPtr a -> Bool Source (<=) :: ForeignPtr a -> ForeignPtr a -> Bool Source (>) :: ForeignPtr a -> ForeignPtr a -> Bool Source (>=) :: ForeignPtr a -> ForeignPtr a -> Bool Source max :: ForeignPtr a -> ForeignPtr a -> ForeignPtr a Source min :: ForeignPtr a -> ForeignPtr a -> ForeignPtr a Source | |
| Ord p => Ord (Par1 p) Source | Since: base-4.7.0.0 |
Defined in GHC.Generics | |
| Ord (FunPtr a) Source | |
| Ord (Ptr a) Source | Since: base-2.1 |
| Integral a => Ord (Ratio a) Source | Since: base-2.0.1 |
| Ord a => Ord (NonEmpty a) Source | Since: base-4.9.0.0 |
Defined in GHC.Base Methodscompare :: NonEmpty a -> NonEmpty a -> Ordering Source (<) :: NonEmpty a -> NonEmpty a -> Bool Source (<=) :: NonEmpty a -> NonEmpty a -> Bool Source (>) :: NonEmpty a -> NonEmpty a -> Bool Source (>=) :: NonEmpty a -> NonEmpty a -> Bool Source | |
| Ord a => Ord (Maybe a) Source | Since: base-2.1 |
| Ord a => Ord (a) | |
| Ord a => Ord [a] | |
| (Ord a, Ord b) => Ord (Either a b) Source | Since: base-2.1 |
Defined in Data.Either Methodscompare :: Either a b -> Either a b -> Ordering Source (<) :: Either a b -> Either a b -> Bool Source (<=) :: Either a b -> Either a b -> Bool Source (>) :: Either a b -> Either a b -> Bool Source (>=) :: Either a b -> Either a b -> Bool Source | |
| Ord (Fixed a) Source | Since: base-2.1 |
| Ord (Proxy s) Source | Since: base-4.7.0.0 |
| Ord a => Ord (Arg a b) Source | Since: base-4.9.0.0 |
| Ord (TypeRep a) Source | Since: base-4.4.0.0 |
Defined in Data.Typeable.Internal | |
| (Ix i, Ord e) => Ord (Array i e) Source | Since: base-2.1 |
Defined in GHC.Arr | |
| Ord (U1 p) Source | Since: base-4.7.0.0 |
| Ord (V1 p) Source | Since: base-4.9.0.0 |
| (Ord a, Ord b) => Ord (a, b) | |
Defined in GHC.Classes | |
| Ord a => Ord (Const a b) Source | Since: base-4.9.0.0 |
Defined in Data.Functor.Const | |
| Ord (f a) => Ord (Ap f a) Source | Since: base-4.12.0.0 |
Defined in Data.Monoid | |
| Ord (f a) => Ord (Alt f a) Source | Since: base-4.8.0.0 |
Defined in Data.Semigroup.Internal | |
| Ord (Coercion a b) Source | Since: base-4.7.0.0 |
Defined in Data.Type.Coercion Methodscompare :: Coercion a b -> Coercion a b -> Ordering Source (<) :: Coercion a b -> Coercion a b -> Bool Source (<=) :: Coercion a b -> Coercion a b -> Bool Source (>) :: Coercion a b -> Coercion a b -> Bool Source (>=) :: Coercion a b -> Coercion a b -> Bool Source | |
| Ord (a :~: b) Source | Since: base-4.7.0.0 |
Defined in Data.Type.Equality | |
| Ord (f p) => Ord (Rec1 f p) Source | Since: base-4.7.0.0 |
Defined in GHC.Generics | |
| Ord (URec (Ptr ()) p) Source | Since: base-4.9.0.0 |
Defined in GHC.Generics Methodscompare :: URec (Ptr ()) p -> URec (Ptr ()) p -> Ordering Source (<) :: URec (Ptr ()) p -> URec (Ptr ()) p -> Bool Source (<=) :: URec (Ptr ()) p -> URec (Ptr ()) p -> Bool Source (>) :: URec (Ptr ()) p -> URec (Ptr ()) p -> Bool Source (>=) :: URec (Ptr ()) p -> URec (Ptr ()) p -> Bool Source max :: URec (Ptr ()) p -> URec (Ptr ()) p -> URec (Ptr ()) p Source min :: URec (Ptr ()) p -> URec (Ptr ()) p -> URec (Ptr ()) p Source | |
| Ord (URec Char p) Source | Since: base-4.9.0.0 |
Defined in GHC.Generics Methodscompare :: URec Char p -> URec Char p -> Ordering Source (<) :: URec Char p -> URec Char p -> Bool Source (<=) :: URec Char p -> URec Char p -> Bool Source (>) :: URec Char p -> URec Char p -> Bool Source (>=) :: URec Char p -> URec Char p -> Bool Source | |
| Ord (URec Double p) Source | Since: base-4.9.0.0 |
Defined in GHC.Generics Methodscompare :: URec Double p -> URec Double p -> Ordering Source (<) :: URec Double p -> URec Double p -> Bool Source (<=) :: URec Double p -> URec Double p -> Bool Source (>) :: URec Double p -> URec Double p -> Bool Source (>=) :: URec Double p -> URec Double p -> Bool Source max :: URec Double p -> URec Double p -> URec Double p Source min :: URec Double p -> URec Double p -> URec Double p Source | |
| Ord (URec Float p) Source | |
Defined in GHC.Generics Methodscompare :: URec Float p -> URec Float p -> Ordering Source (<) :: URec Float p -> URec Float p -> Bool Source (<=) :: URec Float p -> URec Float p -> Bool Source (>) :: URec Float p -> URec Float p -> Bool Source (>=) :: URec Float p -> URec Float p -> Bool Source | |
| Ord (URec Int p) Source | Since: base-4.9.0.0 |
Defined in GHC.Generics Methodscompare :: URec Int p -> URec Int p -> Ordering Source (<) :: URec Int p -> URec Int p -> Bool Source (<=) :: URec Int p -> URec Int p -> Bool Source (>) :: URec Int p -> URec Int p -> Bool Source (>=) :: URec Int p -> URec Int p -> Bool Source | |
| Ord (URec Word p) Source | Since: base-4.9.0.0 |
Defined in GHC.Generics Methodscompare :: URec Word p -> URec Word p -> Ordering Source (<) :: URec Word p -> URec Word p -> Bool Source (<=) :: URec Word p -> URec Word p -> Bool Source (>) :: URec Word p -> URec Word p -> Bool Source (>=) :: URec Word p -> URec Word p -> Bool Source | |
| (Ord a, Ord b, Ord c) => Ord (a, b, c) | |
Defined in GHC.Classes | |
| (Ord1 f, Ord1 g, Ord a) => Ord (Product f g a) Source | Since: base-4.9.0.0 |
Defined in Data.Functor.Product Methodscompare :: Product f g a -> Product f g a -> Ordering Source (<) :: Product f g a -> Product f g a -> Bool Source (<=) :: Product f g a -> Product f g a -> Bool Source (>) :: Product f g a -> Product f g a -> Bool Source (>=) :: Product f g a -> Product f g a -> Bool Source max :: Product f g a -> Product f g a -> Product f g a Source min :: Product f g a -> Product f g a -> Product f g a Source | |
| (Ord1 f, Ord1 g, Ord a) => Ord (Sum f g a) Source | Since: base-4.9.0.0 |
Defined in Data.Functor.Sum | |
| Ord (a :~~: b) Source | Since: base-4.10.0.0 |
Defined in Data.Type.Equality Methodscompare :: (a :~~: b) -> (a :~~: b) -> Ordering Source (<) :: (a :~~: b) -> (a :~~: b) -> Bool Source (<=) :: (a :~~: b) -> (a :~~: b) -> Bool Source (>) :: (a :~~: b) -> (a :~~: b) -> Bool Source (>=) :: (a :~~: b) -> (a :~~: b) -> Bool Source | |
| (Ord (f p), Ord (g p)) => Ord ((f :*: g) p) Source | Since: base-4.7.0.0 |
Defined in GHC.Generics Methodscompare :: (f :*: g) p -> (f :*: g) p -> Ordering Source (<) :: (f :*: g) p -> (f :*: g) p -> Bool Source (<=) :: (f :*: g) p -> (f :*: g) p -> Bool Source (>) :: (f :*: g) p -> (f :*: g) p -> Bool Source (>=) :: (f :*: g) p -> (f :*: g) p -> Bool Source | |
| (Ord (f p), Ord (g p)) => Ord ((f :+: g) p) Source | Since: base-4.7.0.0 |
Defined in GHC.Generics Methodscompare :: (f :+: g) p -> (f :+: g) p -> Ordering Source (<) :: (f :+: g) p -> (f :+: g) p -> Bool Source (<=) :: (f :+: g) p -> (f :+: g) p -> Bool Source (>) :: (f :+: g) p -> (f :+: g) p -> Bool Source (>=) :: (f :+: g) p -> (f :+: g) p -> Bool Source | |
| Ord c => Ord (K1 i c p) Source | Since: base-4.7.0.0 |
Defined in GHC.Generics | |
| (Ord a, Ord b, Ord c, Ord d) => Ord (a, b, c, d) | |
Defined in GHC.Classes Methodscompare :: (a, b, c, d) -> (a, b, c, d) -> Ordering Source (<) :: (a, b, c, d) -> (a, b, c, d) -> Bool Source (<=) :: (a, b, c, d) -> (a, b, c, d) -> Bool Source (>) :: (a, b, c, d) -> (a, b, c, d) -> Bool Source (>=) :: (a, b, c, d) -> (a, b, c, d) -> Bool Source | |
| (Ord1 f, Ord1 g, Ord a) => Ord (Compose f g a) Source | Since: base-4.9.0.0 |
Defined in Data.Functor.Compose Methodscompare :: Compose f g a -> Compose f g a -> Ordering Source (<) :: Compose f g a -> Compose f g a -> Bool Source (<=) :: Compose f g a -> Compose f g a -> Bool Source (>) :: Compose f g a -> Compose f g a -> Bool Source (>=) :: Compose f g a -> Compose f g a -> Bool Source max :: Compose f g a -> Compose f g a -> Compose f g a Source min :: Compose f g a -> Compose f g a -> Compose f g a Source | |
| Ord (f (g p)) => Ord ((f :.: g) p) Source | Since: base-4.7.0.0 |
Defined in GHC.Generics Methodscompare :: (f :.: g) p -> (f :.: g) p -> Ordering Source (<) :: (f :.: g) p -> (f :.: g) p -> Bool Source (<=) :: (f :.: g) p -> (f :.: g) p -> Bool Source (>) :: (f :.: g) p -> (f :.: g) p -> Bool Source (>=) :: (f :.: g) p -> (f :.: g) p -> Bool Source | |
| Ord (f p) => Ord (M1 i c f p) Source | Since: base-4.7.0.0 |
Defined in GHC.Generics Methodscompare :: M1 i c f p -> M1 i c f p -> Ordering Source (<) :: M1 i c f p -> M1 i c f p -> Bool Source (<=) :: M1 i c f p -> M1 i c f p -> Bool Source (>) :: M1 i c f p -> M1 i c f p -> Bool Source (>=) :: M1 i c f p -> M1 i c f p -> Bool Source | |
| (Ord a, Ord b, Ord c, Ord d, Ord e) => Ord (a, b, c, d, e) | |
Defined in GHC.Classes Methodscompare :: (a, b, c, d, e) -> (a, b, c, d, e) -> Ordering Source (<) :: (a, b, c, d, e) -> (a, b, c, d, e) -> Bool Source (<=) :: (a, b, c, d, e) -> (a, b, c, d, e) -> Bool Source (>) :: (a, b, c, d, e) -> (a, b, c, d, e) -> Bool Source (>=) :: (a, b, c, d, e) -> (a, b, c, d, e) -> Bool Source max :: (a, b, c, d, e) -> (a, b, c, d, e) -> (a, b, c, d, e) Source min :: (a, b, c, d, e) -> (a, b, c, d, e) -> (a, b, c, d, e) Source | |
| (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f) => Ord (a, b, c, d, e, f) | |
Defined in GHC.Classes Methodscompare :: (a, b, c, d, e, f) -> (a, b, c, d, e, f) -> Ordering Source (<) :: (a, b, c, d, e, f) -> (a, b, c, d, e, f) -> Bool Source (<=) :: (a, b, c, d, e, f) -> (a, b, c, d, e, f) -> Bool Source (>) :: (a, b, c, d, e, f) -> (a, b, c, d, e, f) -> Bool Source (>=) :: (a, b, c, d, e, f) -> (a, b, c, d, e, f) -> Bool Source max :: (a, b, c, d, e, f) -> (a, b, c, d, e, f) -> (a, b, c, d, e, f) Source min :: (a, b, c, d, e, f) -> (a, b, c, d, e, f) -> (a, b, c, d, e, f) Source | |
| (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g) => Ord (a, b, c, d, e, f, g) | |
Defined in GHC.Classes Methodscompare :: (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) -> Ordering Source (<) :: (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) -> Bool Source (<=) :: (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) -> Bool Source (>) :: (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) -> Bool Source (>=) :: (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) -> Bool Source max :: (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) Source min :: (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) Source | |
| (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h) => Ord (a, b, c, d, e, f, g, h) | |
Defined in GHC.Classes Methodscompare :: (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) -> Ordering Source (<) :: (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) -> Bool Source (<=) :: (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) -> Bool Source (>) :: (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) -> Bool Source (>=) :: (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) -> Bool Source max :: (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) Source min :: (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) Source | |
| (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h, Ord i) => Ord (a, b, c, d, e, f, g, h, i) | |
Defined in GHC.Classes Methodscompare :: (a, b, c, d, e, f, g, h, i) -> (a, b, c, d, e, f, g, h, i) -> Ordering Source (<) :: (a, b, c, d, e, f, g, h, i) -> (a, b, c, d, e, f, g, h, i) -> Bool Source (<=) :: (a, b, c, d, e, f, g, h, i) -> (a, b, c, d, e, f, g, h, i) -> Bool Source (>) :: (a, b, c, d, e, f, g, h, i) -> (a, b, c, d, e, f, g, h, i) -> Bool Source (>=) :: (a, b, c, d, e, f, g, h, i) -> (a, b, c, d, e, f, g, h, i) -> Bool Source max :: (a, b, c, d, e, f, g, h, i) -> (a, b, c, d, e, f, g, h, i) -> (a, b, c, d, e, f, g, h, i) Source min :: (a, b, c, d, e, f, g, h, i) -> (a, b, c, d, e, f, g, h, i) -> (a, b, c, d, e, f, g, h, i) Source | |
| (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h, Ord i, Ord j) => Ord (a, b, c, d, e, f, g, h, i, j) | |
Defined in GHC.Classes Methodscompare :: (a, b, c, d, e, f, g, h, i, j) -> (a, b, c, d, e, f, g, h, i, j) -> Ordering Source (<) :: (a, b, c, d, e, f, g, h, i, j) -> (a, b, c, d, e, f, g, h, i, j) -> Bool Source (<=) :: (a, b, c, d, e, f, g, h, i, j) -> (a, b, c, d, e, f, g, h, i, j) -> Bool Source (>) :: (a, b, c, d, e, f, g, h, i, j) -> (a, b, c, d, e, f, g, h, i, j) -> Bool Source (>=) :: (a, b, c, d, e, f, g, h, i, j) -> (a, b, c, d, e, f, g, h, i, j) -> Bool Source max :: (a, b, c, d, e, f, g, h, i, j) -> (a, b, c, d, e, f, g, h, i, j) -> (a, b, c, d, e, f, g, h, i, j) Source min :: (a, b, c, d, e, f, g, h, i, j) -> (a, b, c, d, e, f, g, h, i, j) -> (a, b, c, d, e, f, g, h, i, j) Source | |
| (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h, Ord i, Ord j, Ord k) => Ord (a, b, c, d, e, f, g, h, i, j, k) | |
Defined in GHC.Classes Methodscompare :: (a, b, c, d, e, f, g, h, i, j, k) -> (a, b, c, d, e, f, g, h, i, j, k) -> Ordering Source (<) :: (a, b, c, d, e, f, g, h, i, j, k) -> (a, b, c, d, e, f, g, h, i, j, k) -> Bool Source (<=) :: (a, b, c, d, e, f, g, h, i, j, k) -> (a, b, c, d, e, f, g, h, i, j, k) -> Bool Source (>) :: (a, b, c, d, e, f, g, h, i, j, k) -> (a, b, c, d, e, f, g, h, i, j, k) -> Bool Source (>=) :: (a, b, c, d, e, f, g, h, i, j, k) -> (a, b, c, d, e, f, g, h, i, j, k) -> Bool Source max :: (a, b, c, d, e, f, g, h, i, j, k) -> (a, b, c, d, e, f, g, h, i, j, k) -> (a, b, c, d, e, f, g, h, i, j, k) Source min :: (a, b, c, d, e, f, g, h, i, j, k) -> (a, b, c, d, e, f, g, h, i, j, k) -> (a, b, c, d, e, f, g, h, i, j, k) Source | |
| (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h, Ord i, Ord j, Ord k, Ord l) => Ord (a, b, c, d, e, f, g, h, i, j, k, l) | |
Defined in GHC.Classes Methodscompare :: (a, b, c, d, e, f, g, h, i, j, k, l) -> (a, b, c, d, e, f, g, h, i, j, k, l) -> Ordering Source (<) :: (a, b, c, d, e, f, g, h, i, j, k, l) -> (a, b, c, d, e, f, g, h, i, j, k, l) -> Bool Source (<=) :: (a, b, c, d, e, f, g, h, i, j, k, l) -> (a, b, c, d, e, f, g, h, i, j, k, l) -> Bool Source (>) :: (a, b, c, d, e, f, g, h, i, j, k, l) -> (a, b, c, d, e, f, g, h, i, j, k, l) -> Bool Source (>=) :: (a, b, c, d, e, f, g, h, i, j, k, l) -> (a, b, c, d, e, f, g, h, i, j, k, l) -> Bool Source max :: (a, b, c, d, e, f, g, h, i, j, k, l) -> (a, b, c, d, e, f, g, h, i, j, k, l) -> (a, b, c, d, e, f, g, h, i, j, k, l) Source min :: (a, b, c, d, e, f, g, h, i, j, k, l) -> (a, b, c, d, e, f, g, h, i, j, k, l) -> (a, b, c, d, e, f, g, h, i, j, k, l) Source | |
| (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h, Ord i, Ord j, Ord k, Ord l, Ord m) => Ord (a, b, c, d, e, f, g, h, i, j, k, l, m) | |
Defined in GHC.Classes Methodscompare :: (a, b, c, d, e, f, g, h, i, j, k, l, m) -> (a, b, c, d, e, f, g, h, i, j, k, l, m) -> Ordering Source (<) :: (a, b, c, d, e, f, g, h, i, j, k, l, m) -> (a, b, c, d, e, f, g, h, i, j, k, l, m) -> Bool Source (<=) :: (a, b, c, d, e, f, g, h, i, j, k, l, m) -> (a, b, c, d, e, f, g, h, i, j, k, l, m) -> Bool Source (>) :: (a, b, c, d, e, f, g, h, i, j, k, l, m) -> (a, b, c, d, e, f, g, h, i, j, k, l, m) -> Bool Source (>=) :: (a, b, c, d, e, f, g, h, i, j, k, l, m) -> (a, b, c, d, e, f, g, h, i, j, k, l, m) -> Bool Source max :: (a, b, c, d, e, f, g, h, i, j, k, l, m) -> (a, b, c, d, e, f, g, h, i, j, k, l, m) -> (a, b, c, d, e, f, g, h, i, j, k, l, m) Source min :: (a, b, c, d, e, f, g, h, i, j, k, l, m) -> (a, b, c, d, e, f, g, h, i, j, k, l, m) -> (a, b, c, d, e, f, g, h, i, j, k, l, m) Source | |
| (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h, Ord i, Ord j, Ord k, Ord l, Ord m, Ord n) => Ord (a, b, c, d, e, f, g, h, i, j, k, l, m, n) | |
Defined in GHC.Classes Methodscompare :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> Ordering Source (<) :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> Bool Source (<=) :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> Bool Source (>) :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> Bool Source (>=) :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> Bool Source max :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n) Source min :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n) Source | |
| (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h, Ord i, Ord j, Ord k, Ord l, Ord m, Ord n, Ord o) => Ord (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) | |
Defined in GHC.Classes Methodscompare :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> Ordering Source (<) :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> Bool Source (<=) :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> Bool Source (>) :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> Bool Source (>=) :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> Bool Source max :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) Source min :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) Source | |
Class Enum defines operations on sequentially ordered types.
The enumFrom... methods are used in Haskell's translation of arithmetic sequences.
Instances of Enum may be derived for any enumeration type (types whose constructors have no fields). The nullary constructors are assumed to be numbered left-to-right by fromEnum from 0 through n-1. See Chapter 10 of the Haskell Report for more details.
For any type that is an instance of class Bounded as well as Enum, the following should hold:
succ maxBound and pred minBound should result in a runtime error.fromEnum and toEnum should give a runtime error if the result value is not representable in the result type. For example, toEnum 7 :: Bool is an error.enumFrom and enumFromThen should be defined with an implicit bound, thus: enumFrom x = enumFromTo x maxBound
enumFromThen x y = enumFromThenTo x y bound
where
bound | fromEnum y >= fromEnum x = maxBound
| otherwise = minBound
the successor of a value. For numeric types, succ adds 1.
the predecessor of a value. For numeric types, pred subtracts 1.
Convert from an Int.
Convert to an Int. It is implementation-dependent what fromEnum returns when applied to a value that is too large to fit in an Int.
Used in Haskell's translation of [n..] with [n..] = enumFrom n, a possible implementation being enumFrom n = n : enumFrom (succ n). For example:
enumFrom 4 :: [Integer] = [4,5,6,7,...]
enumFrom 6 :: [Int] = [6,7,8,9,...,maxBound :: Int]
enumFromThen :: a -> a -> [a] Source
Used in Haskell's translation of [n,n'..] with [n,n'..] = enumFromThen n n', a possible implementation being enumFromThen n n' = n : n' : worker (f x) (f x n'), worker s v = v : worker s (s v), x = fromEnum n' - fromEnum n and f n y
| n > 0 = f (n - 1) (succ y)
| n < 0 = f (n + 1) (pred y)
| otherwise = y For example:
enumFromThen 4 6 :: [Integer] = [4,6,8,10...]
enumFromThen 6 2 :: [Int] = [6,2,-2,-6,...,minBound :: Int]
enumFromTo :: a -> a -> [a] Source
Used in Haskell's translation of [n..m] with [n..m] = enumFromTo n m, a possible implementation being enumFromTo n m
| n <= m = n : enumFromTo (succ n) m
| otherwise = []. For example:
enumFromTo 6 10 :: [Int] = [6,7,8,9,10]
enumFromTo 42 1 :: [Integer] = []
enumFromThenTo :: a -> a -> a -> [a] Source
Used in Haskell's translation of [n,n'..m] with [n,n'..m] = enumFromThenTo n n' m, a possible implementation being enumFromThenTo n n' m = worker (f x) (c x) n m, x = fromEnum n' - fromEnum n, c x = bool (>=) ((x 0) f n y
| n > 0 = f (n - 1) (succ y)
| n < 0 = f (n + 1) (pred y)
| otherwise = y and worker s c v m
| c v m = v : worker s c (s v) m
| otherwise = [] For example:
enumFromThenTo 4 2 -6 :: [Integer] = [4,2,0,-2,-4,-6]
enumFromThenTo 6 8 2 :: [Int] = []
The Bounded class is used to name the upper and lower limits of a type. Ord is not a superclass of Bounded since types that are not totally ordered may also have upper and lower bounds.
The Bounded class may be derived for any enumeration type; minBound is the first constructor listed in the data declaration and maxBound is the last. Bounded may also be derived for single-constructor datatypes whose constituent types are in Bounded.
A fixed-precision integer type with at least the range [-2^29 .. 2^29-1]. The exact range for a given implementation can be determined by using minBound and maxBound from the Bounded class.
| Data Int Source | Since: base-4.0.0.0 |
Defined in Data.Data Methodsgfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Int -> c Int Source gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Int Source toConstr :: Int -> Constr Source dataTypeOf :: Int -> DataType Source dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Int) Source dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Int) Source gmapT :: (forall b. Data b => b -> b) -> Int -> Int Source gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Int -> r Source gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Int -> r Source gmapQ :: (forall d. Data d => d -> u) -> Int -> [u] Source gmapQi :: Int -> (forall d. Data d => d -> u) -> Int -> u Source gmapM :: Monad m => (forall d. Data d => d -> m d) -> Int -> m Int Source gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Int -> m Int Source gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Int -> m Int Source | |
| Storable Int Source | Since: base-2.1 |
| Bits Int Source | Since: base-2.1 |
Defined in GHC.Bits Methods(.&.) :: Int -> Int -> Int Source (.|.) :: Int -> Int -> Int Source xor :: Int -> Int -> Int Source complement :: Int -> Int Source shift :: Int -> Int -> Int Source rotate :: Int -> Int -> Int Source setBit :: Int -> Int -> Int Source clearBit :: Int -> Int -> Int Source complementBit :: Int -> Int -> Int Source testBit :: Int -> Int -> Bool Source bitSizeMaybe :: Int -> Maybe Int Source isSigned :: Int -> Bool Source shiftL :: Int -> Int -> Int Source unsafeShiftL :: Int -> Int -> Int Source shiftR :: Int -> Int -> Int Source unsafeShiftR :: Int -> Int -> Int Source rotateL :: Int -> Int -> Int Source | |
| FiniteBits Int Source | Since: base-4.6.0.0 |
Defined in GHC.Bits MethodsfiniteBitSize :: Int -> Int Source countLeadingZeros :: Int -> Int Source countTrailingZeros :: Int -> Int Source | |
| Bounded Int Source | Since: base-2.1 |
| Enum Int Source | Since: base-2.1 |
Defined in GHC.Enum | |
| Ix Int Source | Since: base-2.1 |
| Num Int Source | Since: base-2.1 |
| Read Int Source | Since: base-2.1 |
| Integral Int Source | Since: base-2.0.1 |
| Real Int Source | Since: base-2.0.1 |
Defined in GHC.Real MethodstoRational :: Int -> Rational Source | |
| Show Int Source | Since: base-2.1 |
| PrintfArg Int Source | Since: base-2.1 |
Defined in Text.Printf | |
| Eq Int | |
| Ord Int | |
| Generic1 (URec Int :: k -> Type) Source | |
| Foldable (UInt :: Type -> Type) Source | Since: base-4.9.0.0 |
Defined in Data.Foldable Methodsfold :: Monoid m => UInt m -> m Source foldMap :: Monoid m => (a -> m) -> UInt a -> m Source foldMap' :: Monoid m => (a -> m) -> UInt a -> m Source foldr :: (a -> b -> b) -> b -> UInt a -> b Source foldr' :: (a -> b -> b) -> b -> UInt a -> b Source foldl :: (b -> a -> b) -> b -> UInt a -> b Source foldl' :: (b -> a -> b) -> b -> UInt a -> b Source foldr1 :: (a -> a -> a) -> UInt a -> a Source foldl1 :: (a -> a -> a) -> UInt a -> a Source toList :: UInt a -> [a] Source length :: UInt a -> Int Source elem :: Eq a => a -> UInt a -> Bool Source maximum :: Ord a => UInt a -> a Source minimum :: Ord a => UInt a -> a Source | |
| Traversable (UInt :: Type -> Type) Source | Since: base-4.9.0.0 |
| Functor (URec Int :: Type -> Type) Source | Since: base-4.9.0.0 |
| Generic (URec Int p) Source | |
| Show (URec Int p) Source | Since: base-4.9.0.0 |
| Eq (URec Int p) Source | Since: base-4.9.0.0 |
| Ord (URec Int p) Source | Since: base-4.9.0.0 |
Defined in GHC.Generics Methodscompare :: URec Int p -> URec Int p -> Ordering Source (<) :: URec Int p -> URec Int p -> Bool Source (<=) :: URec Int p -> URec Int p -> Bool Source (>) :: URec Int p -> URec Int p -> Bool Source (>=) :: URec Int p -> URec Int p -> Bool Source | |
| data URec Int (p :: k) Source |
Used for marking occurrences of Since: base-4.9.0.0 |
| type Rep1 (URec Int :: k -> Type) Source | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
| type Rep (URec Int p) Source | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
Arbitrary precision integers. In contrast with fixed-size integral types such as Int, the Integer type represents the entire infinite range of integers.
Integers are stored in a kind of sign-magnitude form, hence do not expect two's complement form when using bit operations.
If the value is small (fit into an Int), IS constructor is used. Otherwise Integer and IN constructors are used to store a BigNat representing respectively the positive or the negative value magnitude.
Invariant: Integer and IN are used iff value doesn't fit in IS
Single-precision floating point numbers. It is desirable that this type be at least equal in range and precision to the IEEE single-precision type.
| Data Float Source | Since: base-4.0.0.0 |
Defined in Data.Data Methodsgfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Float -> c Float Source gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Float Source toConstr :: Float -> Constr Source dataTypeOf :: Float -> DataType Source dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Float) Source dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Float) Source gmapT :: (forall b. Data b => b -> b) -> Float -> Float Source gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Float -> r Source gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Float -> r Source gmapQ :: (forall d. Data d => d -> u) -> Float -> [u] Source gmapQi :: Int -> (forall d. Data d => d -> u) -> Float -> u Source gmapM :: Monad m => (forall d. Data d => d -> m d) -> Float -> m Float Source gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Float -> m Float Source gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Float -> m Float Source | |
| Storable Float Source | Since: base-2.1 |
Defined in Foreign.Storable | |
| Enum Float Source | Since: base-2.1 |
| Floating Float Source | Since: base-2.1 |
| RealFloat Float Source | Since: base-2.1 |
Defined in GHC.Float MethodsfloatRadix :: Float -> Integer Source floatDigits :: Float -> Int Source floatRange :: Float -> (Int, Int) Source decodeFloat :: Float -> (Integer, Int) Source encodeFloat :: Integer -> Int -> Float Source exponent :: Float -> Int Source significand :: Float -> Float Source scaleFloat :: Int -> Float -> Float Source isInfinite :: Float -> Bool Source isDenormalized :: Float -> Bool Source isNegativeZero :: Float -> Bool Source | |
| Num Float Source |
Note that due to the presence of >>> 0/0 + (negate 0/0 :: Float) NaN Also note that due to the presence of -0, >>> 0 + (-0 :: Float) 0.0 Since: base-2.1 |
| Read Float Source | Since: base-2.1 |
| Fractional Float Source |
Note that due to the presence of >>> 0/0 * (recip 0/0 :: Float) NaN Since: base-2.1 |
| Real Float Source | Since: base-2.1 |
Defined in GHC.Float MethodstoRational :: Float -> Rational Source | |
| RealFrac Float Source | Since: base-2.1 |
| Show Float Source | Since: base-2.1 |
| PrintfArg Float Source | Since: base-2.1 |
Defined in Text.Printf | |
| Eq Float |
Note that due to the presence of >>> 0/0 == (0/0 :: Float) False Also note that >>> 0 == (-0 :: Float) True >>> recip 0 == recip (-0 :: Float) False |
| Ord Float |
Note that due to the presence of >>> 0/0 <= (0/0 :: Float) False Also note that, due to the same, >>> (0/0 :: Float) > 1 False >>> compare (0/0 :: Float) 1 GT |
Defined in GHC.Classes | |
| Generic1 (URec Float :: k -> Type) Source | |
| Foldable (UFloat :: Type -> Type) Source | Since: base-4.9.0.0 |
Defined in Data.Foldable Methodsfold :: Monoid m => UFloat m -> m Source foldMap :: Monoid m => (a -> m) -> UFloat a -> m Source foldMap' :: Monoid m => (a -> m) -> UFloat a -> m Source foldr :: (a -> b -> b) -> b -> UFloat a -> b Source foldr' :: (a -> b -> b) -> b -> UFloat a -> b Source foldl :: (b -> a -> b) -> b -> UFloat a -> b Source foldl' :: (b -> a -> b) -> b -> UFloat a -> b Source foldr1 :: (a -> a -> a) -> UFloat a -> a Source foldl1 :: (a -> a -> a) -> UFloat a -> a Source toList :: UFloat a -> [a] Source null :: UFloat a -> Bool Source length :: UFloat a -> Int Source elem :: Eq a => a -> UFloat a -> Bool Source maximum :: Ord a => UFloat a -> a Source minimum :: Ord a => UFloat a -> a Source | |
| Traversable (UFloat :: Type -> Type) Source | Since: base-4.9.0.0 |
Defined in Data.Traversable | |
| Functor (URec Float :: Type -> Type) Source | Since: base-4.9.0.0 |
| Generic (URec Float p) Source | |
| Show (URec Float p) Source | |
| Eq (URec Float p) Source | |
| Ord (URec Float p) Source | |
Defined in GHC.Generics Methodscompare :: URec Float p -> URec Float p -> Ordering Source (<) :: URec Float p -> URec Float p -> Bool Source (<=) :: URec Float p -> URec Float p -> Bool Source (>) :: URec Float p -> URec Float p -> Bool Source (>=) :: URec Float p -> URec Float p -> Bool Source | |
| data URec Float (p :: k) Source |
Used for marking occurrences of Since: base-4.9.0.0 |
| type Rep1 (URec Float :: k -> Type) Source | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
| type Rep (URec Float p) Source | |
Defined in GHC.Generics | |
Double-precision floating point numbers. It is desirable that this type be at least equal in range and precision to the IEEE double-precision type.
| Data Double Source | Since: base-4.0.0.0 |
Defined in Data.Data Methodsgfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Double -> c Double Source gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Double Source toConstr :: Double -> Constr Source dataTypeOf :: Double -> DataType Source dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Double) Source dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Double) Source gmapT :: (forall b. Data b => b -> b) -> Double -> Double Source gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Double -> r Source gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Double -> r Source gmapQ :: (forall d. Data d => d -> u) -> Double -> [u] Source gmapQi :: Int -> (forall d. Data d => d -> u) -> Double -> u Source gmapM :: Monad m => (forall d. Data d => d -> m d) -> Double -> m Double Source gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Double -> m Double Source gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Double -> m Double Source | |
| Storable Double Source | Since: base-2.1 |
Defined in Foreign.Storable MethodssizeOf :: Double -> Int Source alignment :: Double -> Int Source peekElemOff :: Ptr Double -> Int -> IO Double Source pokeElemOff :: Ptr Double -> Int -> Double -> IO () Source peekByteOff :: Ptr b -> Int -> IO Double Source pokeByteOff :: Ptr b -> Int -> Double -> IO () Source | |
| Enum Double Source | Since: base-2.1 |
Defined in GHC.Float Methodssucc :: Double -> Double Source pred :: Double -> Double Source toEnum :: Int -> Double Source fromEnum :: Double -> Int Source enumFrom :: Double -> [Double] Source enumFromThen :: Double -> Double -> [Double] Source enumFromTo :: Double -> Double -> [Double] Source enumFromThenTo :: Double -> Double -> Double -> [Double] Source | |
| Floating Double Source | Since: base-2.1 |
Defined in GHC.Float Methodsexp :: Double -> Double Source log :: Double -> Double Source sqrt :: Double -> Double Source (**) :: Double -> Double -> Double Source logBase :: Double -> Double -> Double Source sin :: Double -> Double Source cos :: Double -> Double Source tan :: Double -> Double Source asin :: Double -> Double Source acos :: Double -> Double Source atan :: Double -> Double Source sinh :: Double -> Double Source cosh :: Double -> Double Source tanh :: Double -> Double Source asinh :: Double -> Double Source acosh :: Double -> Double Source atanh :: Double -> Double Source log1p :: Double -> Double Source expm1 :: Double -> Double Source | |
| RealFloat Double Source | Since: base-2.1 |
Defined in GHC.Float MethodsfloatRadix :: Double -> Integer Source floatDigits :: Double -> Int Source floatRange :: Double -> (Int, Int) Source decodeFloat :: Double -> (Integer, Int) Source encodeFloat :: Integer -> Int -> Double Source exponent :: Double -> Int Source significand :: Double -> Double Source scaleFloat :: Int -> Double -> Double Source isNaN :: Double -> Bool Source isInfinite :: Double -> Bool Source isDenormalized :: Double -> Bool Source isNegativeZero :: Double -> Bool Source | |
| Num Double Source |
Note that due to the presence of >>> 0/0 + (negate 0/0 :: Double) NaN Also note that due to the presence of -0, >>> 0 + (-0 :: Double) 0.0 Since: base-2.1 |
| Read Double Source | Since: base-2.1 |
| Fractional Double Source |
Note that due to the presence of >>> 0/0 * (recip 0/0 :: Double) NaN Since: base-2.1 |
| Real Double Source | Since: base-2.1 |
Defined in GHC.Float MethodstoRational :: Double -> Rational Source | |
| RealFrac Double Source | Since: base-2.1 |
| Show Double Source | Since: base-2.1 |
| PrintfArg Double Source | Since: base-2.1 |
Defined in Text.Printf | |
| Eq Double |
Note that due to the presence of >>> 0/0 == (0/0 :: Double) False Also note that >>> 0 == (-0 :: Double) True >>> recip 0 == recip (-0 :: Double) False |
| Ord Double |
Note that due to the presence of >>> 0/0 <= (0/0 :: Double) False Also note that, due to the same, >>> (0/0 :: Double) > 1 False >>> compare (0/0 :: Double) 1 GT |
Defined in GHC.Classes | |
| Generic1 (URec Double :: k -> Type) Source | |
| Foldable (UDouble :: Type -> Type) Source | Since: base-4.9.0.0 |
Defined in Data.Foldable Methodsfold :: Monoid m => UDouble m -> m Source foldMap :: Monoid m => (a -> m) -> UDouble a -> m Source foldMap' :: Monoid m => (a -> m) -> UDouble a -> m Source foldr :: (a -> b -> b) -> b -> UDouble a -> b Source foldr' :: (a -> b -> b) -> b -> UDouble a -> b Source foldl :: (b -> a -> b) -> b -> UDouble a -> b Source foldl' :: (b -> a -> b) -> b -> UDouble a -> b Source foldr1 :: (a -> a -> a) -> UDouble a -> a Source foldl1 :: (a -> a -> a) -> UDouble a -> a Source toList :: UDouble a -> [a] Source null :: UDouble a -> Bool Source length :: UDouble a -> Int Source elem :: Eq a => a -> UDouble a -> Bool Source maximum :: Ord a => UDouble a -> a Source minimum :: Ord a => UDouble a -> a Source | |
| Traversable (UDouble :: Type -> Type) Source | Since: base-4.9.0.0 |
Defined in Data.Traversable | |
| Functor (URec Double :: Type -> Type) Source | Since: base-4.9.0.0 |
| Generic (URec Double p) Source | |
| Show (URec Double p) Source | Since: base-4.9.0.0 |
| Eq (URec Double p) Source | Since: base-4.9.0.0 |
| Ord (URec Double p) Source | Since: base-4.9.0.0 |
Defined in GHC.Generics Methodscompare :: URec Double p -> URec Double p -> Ordering Source (<) :: URec Double p -> URec Double p -> Bool Source (<=) :: URec Double p -> URec Double p -> Bool Source (>) :: URec Double p -> URec Double p -> Bool Source (>=) :: URec Double p -> URec Double p -> Bool Source max :: URec Double p -> URec Double p -> URec Double p Source min :: URec Double p -> URec Double p -> URec Double p Source | |
| data URec Double (p :: k) Source |
Used for marking occurrences of Since: base-4.9.0.0 |
| type Rep1 (URec Double :: k -> Type) Source | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
| type Rep (URec Double p) Source | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
type Rational = Ratio Integer Source
Arbitrary-precision rational numbers, represented as a ratio of two Integer values. A rational number may be constructed using the % operator.
A Word is an unsigned integral type, with the same size as Int.
| Data Word Source | Since: base-4.0.0.0 |
Defined in Data.Data Methodsgfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Word -> c Word Source gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Word Source toConstr :: Word -> Constr Source dataTypeOf :: Word -> DataType Source dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Word) Source dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Word) Source gmapT :: (forall b. Data b => b -> b) -> Word -> Word Source gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Word -> r Source gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Word -> r Source gmapQ :: (forall d. Data d => d -> u) -> Word -> [u] Source gmapQi :: Int -> (forall d. Data d => d -> u) -> Word -> u Source gmapM :: Monad m => (forall d. Data d => d -> m d) -> Word -> m Word Source gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Word -> m Word Source gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Word -> m Word Source | |
| Storable Word Source | Since: base-2.1 |
Defined in Foreign.Storable | |
| Bits Word Source | Since: base-2.1 |
Defined in GHC.Bits Methods(.&.) :: Word -> Word -> Word Source (.|.) :: Word -> Word -> Word Source xor :: Word -> Word -> Word Source complement :: Word -> Word Source shift :: Word -> Int -> Word Source rotate :: Word -> Int -> Word Source setBit :: Word -> Int -> Word Source clearBit :: Word -> Int -> Word Source complementBit :: Word -> Int -> Word Source testBit :: Word -> Int -> Bool Source bitSizeMaybe :: Word -> Maybe Int Source isSigned :: Word -> Bool Source shiftL :: Word -> Int -> Word Source unsafeShiftL :: Word -> Int -> Word Source shiftR :: Word -> Int -> Word Source unsafeShiftR :: Word -> Int -> Word Source rotateL :: Word -> Int -> Word Source | |
| FiniteBits Word Source | Since: base-4.6.0.0 |
Defined in GHC.Bits MethodsfiniteBitSize :: Word -> Int Source countLeadingZeros :: Word -> Int Source countTrailingZeros :: Word -> Int Source | |
| Bounded Word Source | Since: base-2.1 |
| Enum Word Source | Since: base-2.1 |
| Ix Word Source | Since: base-4.6.0.0 |
| Num Word Source | Since: base-2.1 |
| Read Word Source | Since: base-4.5.0.0 |
| Integral Word Source | Since: base-2.1 |
| Real Word Source | Since: base-2.1 |
Defined in GHC.Real MethodstoRational :: Word -> Rational Source | |
| Show Word Source | Since: base-2.1 |
| PrintfArg Word Source | Since: base-2.1 |
Defined in Text.Printf | |
| Eq Word | |
| Ord Word | |
| Generic1 (URec Word :: k -> Type) Source | |
| Foldable (UWord :: Type -> Type) Source | Since: base-4.9.0.0 |
Defined in Data.Foldable Methodsfold :: Monoid m => UWord m -> m Source foldMap :: Monoid m => (a -> m) -> UWord a -> m Source foldMap' :: Monoid m => (a -> m) -> UWord a -> m Source foldr :: (a -> b -> b) -> b -> UWord a -> b Source foldr' :: (a -> b -> b) -> b -> UWord a -> b Source foldl :: (b -> a -> b) -> b -> UWord a -> b Source foldl' :: (b -> a -> b) -> b -> UWord a -> b Source foldr1 :: (a -> a -> a) -> UWord a -> a Source foldl1 :: (a -> a -> a) -> UWord a -> a Source toList :: UWord a -> [a] Source null :: UWord a -> Bool Source length :: UWord a -> Int Source elem :: Eq a => a -> UWord a -> Bool Source maximum :: Ord a => UWord a -> a Source minimum :: Ord a => UWord a -> a Source | |
| Traversable (UWord :: Type -> Type) Source | Since: base-4.9.0.0 |
| Functor (URec Word :: Type -> Type) Source | Since: base-4.9.0.0 |
| Generic (URec Word p) Source | |
| Show (URec Word p) Source | Since: base-4.9.0.0 |
| Eq (URec Word p) Source | Since: base-4.9.0.0 |
| Ord (URec Word p) Source | Since: base-4.9.0.0 |
Defined in GHC.Generics Methodscompare :: URec Word p -> URec Word p -> Ordering Source (<) :: URec Word p -> URec Word p -> Bool Source (<=) :: URec Word p -> URec Word p -> Bool Source (>) :: URec Word p -> URec Word p -> Bool Source (>=) :: URec Word p -> URec Word p -> Bool Source | |
| data URec Word (p :: k) Source |
Used for marking occurrences of Since: base-4.9.0.0 |
| type Rep1 (URec Word :: k -> Type) Source | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
| type Rep (URec Word p) Source | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
Basic numeric class.
The Haskell Report defines no laws for Num. However, (+) and (*) are customarily expected to define a ring and have the following properties:
(+)(x + y) + z = x + (y + z)
(+)x + y = y + x
fromInteger 0 is the additive identityx + fromInteger 0 = x
negate gives the additive inversex + negate x = fromInteger 0
(*)(x * y) * z = x * (y * z)
fromInteger 1 is the multiplicative identityx * fromInteger 1 = x and fromInteger 1 * x = x
(*) with respect to (+)a * (b + c) = (a * b) + (a * c) and (b + c) * a = (b * a) + (c * a)
Note that it isn't customarily expected that a type instance of both Num and Ord implement an ordered ring. Indeed, in base only Integer and Rational do.
(+) :: a -> a -> a infixl 6 Source
(-) :: a -> a -> a infixl 6 Source
(*) :: a -> a -> a infixl 7 Source
Unary negation.
Absolute value.
Sign of a number. The functions abs and signum should satisfy the law:
abs x * signum x == x
For real numbers, the signum is either -1 (negative), 0 (zero) or 1 (positive).
fromInteger :: Integer -> a Source
Conversion from an Integer. An integer literal represents the application of the function fromInteger to the appropriate value of type Integer, so such literals have type (Num a) => a.
class (Num a, Ord a) => Real a where Source
toRational :: a -> Rational Source
the rational equivalent of its real argument with full precision
class (Real a, Enum a) => Integral a where Source
Integral numbers, supporting integer division.
The Haskell Report defines no laws for Integral. However, Integral instances are customarily expected to define a Euclidean domain and have the following properties for the div/mod and quot/rem pairs, given suitable Euclidean functions f and g:
x = y * quot x y + rem x y with rem x y = fromInteger 0 or g (rem x y) < g y
x = y * div x y + mod x y with mod x y = fromInteger 0 or f (mod x y) < f y
An example of a suitable Euclidean function, for Integer's instance, is abs.
quot :: a -> a -> a infixl 7 Source
integer division truncated toward zero
WARNING: This function is partial (because it throws when 0 is passed as the divisor) for all the integer types in base.
rem :: a -> a -> a infixl 7 Source
integer remainder, satisfying
(x `quot` y)*y + (x `rem` y) == x
WARNING: This function is partial (because it throws when 0 is passed as the divisor) for all the integer types in base.
div :: a -> a -> a infixl 7 Source
integer division truncated toward negative infinity
WARNING: This function is partial (because it throws when 0 is passed as the divisor) for all the integer types in base.
mod :: a -> a -> a infixl 7 Source
integer modulus, satisfying
(x `div` y)*y + (x `mod` y) == x
WARNING: This function is partial (because it throws when 0 is passed as the divisor) for all the integer types in base.
quotRem :: a -> a -> (a, a) Source
WARNING: This function is partial (because it throws when 0 is passed as the divisor) for all the integer types in base.
divMod :: a -> a -> (a, a) Source
WARNING: This function is partial (because it throws when 0 is passed as the divisor) for all the integer types in base.
toInteger :: a -> Integer Source
conversion to Integer
class Num a => Fractional a where Source
Fractional numbers, supporting real division.
The Haskell Report defines no laws for Fractional. However, (+) and (*) are customarily expected to define a division ring and have the following properties:
recip gives the multiplicative inversex * recip x = recip x * x = fromInteger 1
Note that it isn't customarily expected that a type instance of Fractional implement a field. However, all instances in base do.
fromRational, (recip | (/))
(/) :: a -> a -> a infixl 7 Source
Fractional division.
Reciprocal fraction.
fromRational :: Rational -> a Source
Conversion from a Rational (that is Ratio Integer). A floating literal stands for an application of fromRational to a value of type Rational, so such literals have type (Fractional a) => a.
| Fractional CDouble Source | |
| Fractional CFloat Source | |
| Fractional Double Source |
Note that due to the presence of >>> 0/0 * (recip 0/0 :: Double) NaN Since: base-2.1 |
| Fractional Float Source |
Note that due to the presence of >>> 0/0 * (recip 0/0 :: Float) NaN Since: base-2.1 |
| RealFloat a => Fractional (Complex a) Source | Since: base-2.1 |
| Fractional a => Fractional (Identity a) Source | Since: base-4.9.0.0 |
| Fractional a => Fractional (Down a) Source | Since: base-4.14.0.0 |
| Integral a => Fractional (Ratio a) Source | Since: base-2.0.1 |
| HasResolution a => Fractional (Fixed a) Source | Since: base-2.1 |
| Fractional a => Fractional (Op a b) Source | |
| Fractional a => Fractional (Const a b) Source | Since: base-4.9.0.0 |
class Fractional a => Floating a where Source
Trigonometric and hyperbolic functions and related functions.
The Haskell Report defines no laws for Floating. However, (+), (*) and exp are customarily expected to define an exponential field and have the following properties:
exp (a + b) = exp a * exp b
exp (fromInteger 0) = fromInteger 1
pi, exp, log, sin, cos, asin, acos, atan, sinh, cosh, asinh, acosh, atanh
class (Real a, Fractional a) => RealFrac a where Source
Extracting components of fractions.
properFraction :: Integral b => a -> (b, a) Source
The function properFraction takes a real fractional number x and returns a pair (n,f) such that x = n+f, and:
n is an integral number with the same sign as x; andf is a fraction with the same type and sign as x, and with absolute value less than 1.The default definitions of the ceiling, floor, truncate and round functions are in terms of properFraction.
truncate :: Integral b => a -> b Source
truncate x returns the integer nearest x between zero and x
round :: Integral b => a -> b Source
round x returns the nearest integer to x; the even integer if x is equidistant between two integers
ceiling :: Integral b => a -> b Source
ceiling x returns the least integer not less than x
floor :: Integral b => a -> b Source
floor x returns the greatest integer not greater than x
| RealFrac CDouble Source | |
| RealFrac CFloat Source | |
| RealFrac Double Source | Since: base-2.1 |
| RealFrac Float Source | Since: base-2.1 |
| RealFrac a => RealFrac (Identity a) Source | Since: base-4.9.0.0 |
| RealFrac a => RealFrac (Down a) Source | Since: base-4.14.0.0 |
| Integral a => RealFrac (Ratio a) Source | Since: base-2.0.1 |
| HasResolution a => RealFrac (Fixed a) Source | Since: base-2.1 |
| RealFrac a => RealFrac (Const a b) Source | Since: base-4.9.0.0 |
class (RealFrac a, Floating a) => RealFloat a where Source
Efficient, machine-independent access to the components of a floating-point number.
floatRadix, floatDigits, floatRange, decodeFloat, encodeFloat, isNaN, isInfinite, isDenormalized, isNegativeZero, isIEEE
floatRadix :: a -> Integer Source
a constant function, returning the radix of the representation (often 2)
floatDigits :: a -> Int Source
a constant function, returning the number of digits of floatRadix in the significand
floatRange :: a -> (Int, Int) Source
a constant function, returning the lowest and highest values the exponent may assume
decodeFloat :: a -> (Integer, Int) Source
The function decodeFloat applied to a real floating-point number returns the significand expressed as an Integer and an appropriately scaled exponent (an Int). If decodeFloat x yields (m,n), then x is equal in value to m*b^^n, where b is the floating-point radix, and furthermore, either m and n are both zero or else b^(d-1) <= abs m < b^d, where d is the value of floatDigits x. In particular, decodeFloat 0 = (0,0). If the type contains a negative zero, also decodeFloat (-0.0) = (0,0). The result of decodeFloat x is unspecified if either of isNaN x or isInfinite x is True.
encodeFloat :: Integer -> Int -> a Source
encodeFloat performs the inverse of decodeFloat in the sense that for finite x with the exception of -0.0, uncurry encodeFloat (decodeFloat x) = x. encodeFloat m n is one of the two closest representable floating-point numbers to m*b^^n (or ±Infinity if overflow occurs); usually the closer, but if m contains too many bits, the result may be rounded in the wrong direction.
exponent corresponds to the second component of decodeFloat. exponent 0 = 0 and for finite nonzero x, exponent x = snd (decodeFloat x) + floatDigits x. If x is a finite floating-point number, it is equal in value to significand x * b ^^ exponent x, where b is the floating-point radix. The behaviour is unspecified on infinite or NaN values.
significand :: a -> a Source
The first component of decodeFloat, scaled to lie in the open interval (-1,1), either 0.0 or of absolute value >= 1/b, where b is the floating-point radix. The behaviour is unspecified on infinite or NaN values.
scaleFloat :: Int -> a -> a Source
multiplies a floating-point number by an integer power of the radix
True if the argument is an IEEE "not-a-number" (NaN) value
isInfinite :: a -> Bool Source
True if the argument is an IEEE infinity or negative infinity
isDenormalized :: a -> Bool Source
True if the argument is too small to be represented in normalized format
isNegativeZero :: a -> Bool Source
True if the argument is an IEEE negative zero
True if the argument is an IEEE floating point number
a version of arctangent taking two real floating-point arguments. For real floating x and y, atan2 y x computes the angle (from the positive x-axis) of the vector from the origin to the point (x,y). atan2 y x returns a value in the range [-pi, pi]. It follows the Common Lisp semantics for the origin when signed zeroes are supported. atan2 y 1, with y in a type that is RealFloat, should return the same value as atan y. A default definition of atan2 is provided, but implementors can provide a more accurate implementation.
subtract :: Num a => a -> a -> a Source
Because - is treated specially in the Haskell grammar, (- e) is not a section, but an application of prefix negation. However, (subtract exp) is equivalent to the disallowed section.
even :: Integral a => a -> Bool Source
odd :: Integral a => a -> Bool Source
gcd :: Integral a => a -> a -> a Source
gcd x y is the non-negative factor of both x and y of which every common factor of x and y is also a factor; for example gcd 4 2 = 2, gcd (-4) 6 = 2, gcd 0 4 = 4. gcd 0 0 = 0. (That is, the common divisor that is "greatest" in the divisibility preordering.)
Note: Since for signed fixed-width integer types, abs minBound < 0, the result may be negative if one of the arguments is minBound (and necessarily is if the other is 0 or minBound) for such types.
lcm :: Integral a => a -> a -> a Source
lcm x y is the smallest positive integer that both x and y divide.
(^) :: (Num a, Integral b) => a -> b -> a infixr 8 Source
raise a number to a non-negative integral power
(^^) :: (Fractional a, Integral b) => a -> b -> a infixr 8 Source
raise a number to an integral power
fromIntegral :: (Integral a, Num b) => a -> b Source
General coercion from Integral types.
WARNING: This function performs silent truncation if the result type is not at least as big as the argument's type.
realToFrac :: (Real a, Fractional b) => a -> b Source
General coercion to Fractional types.
WARNING: This function goes through the Rational type, which does not have values for NaN for example. This means it does not round-trip.
For Double it also behaves differently with or without -O0:
Prelude> realToFrac nan -- With -O0 -Infinity Prelude> realToFrac nan NaN
class Semigroup a where Source
The class of semigroups (types with an associative binary operation).
Instances should satisfy the following:
Since: base-4.9.0.0
(<>) :: a -> a -> a infixr 6 Source
An associative operation.
>>> [1,2,3] <> [4,5,6] [1,2,3,4,5,6]
| Semigroup ByteArray Source | Since: base-4.17.0.0 |
| Semigroup All Source | Since: base-4.9.0.0 |
| Semigroup Any Source | Since: base-4.9.0.0 |
| Semigroup Void Source | Since: base-4.9.0.0 |
| Semigroup Event Source | Since: base-4.10.0.0 |
| Semigroup Lifetime Source | Since: base-4.10.0.0 |
| Semigroup Ordering Source | Since: base-4.9.0.0 |
| Semigroup () Source | Since: base-4.9.0.0 |
| Bits a => Semigroup (And a) Source | Since: base-4.16 |
| FiniteBits a => Semigroup (Iff a) Source |
This constraint is arguably too strong. However, as some types (such as Since: base-4.16 |
| Bits a => Semigroup (Ior a) Source | Since: base-4.16 |
| Bits a => Semigroup (Xor a) Source | Since: base-4.16 |
| Semigroup (Comparison a) Source |
(<>) :: Comparison a -> Comparison a -> Comparison a Comparison cmp <> Comparison cmp' = Comparison a a' -> cmp a a' <> cmp a a' |
Defined in Data.Functor.Contravariant Methods(<>) :: Comparison a -> Comparison a -> Comparison a Source sconcat :: NonEmpty (Comparison a) -> Comparison a Source stimes :: Integral b => b -> Comparison a -> Comparison a Source | |
| Semigroup (Equivalence a) Source |
(<>) :: Equivalence a -> Equivalence a -> Equivalence a Equivalence equiv <> Equivalence equiv' = Equivalence a b -> equiv a b && equiv' a b |
Defined in Data.Functor.Contravariant Methods(<>) :: Equivalence a -> Equivalence a -> Equivalence a Source sconcat :: NonEmpty (Equivalence a) -> Equivalence a Source stimes :: Integral b => b -> Equivalence a -> Equivalence a Source | |
| Semigroup (Predicate a) Source |
(<>) :: Predicate a -> Predicate a -> Predicate a Predicate pred <> Predicate pred' = Predicate a -> pred a && pred' a |
| Semigroup a => Semigroup (Identity a) Source | Since: base-4.9.0.0 |
| Semigroup (First a) Source | Since: base-4.9.0.0 |
| Semigroup (Last a) Source | Since: base-4.9.0.0 |
| Semigroup a => Semigroup (Down a) Source | Since: base-4.11.0.0 |
| Semigroup (First a) Source | Since: base-4.9.0.0 |
| Semigroup (Last a) Source | Since: base-4.9.0.0 |
| Ord a => Semigroup (Max a) Source | Since: base-4.9.0.0 |
| Ord a => Semigroup (Min a) Source | Since: base-4.9.0.0 |
| Monoid m => Semigroup (WrappedMonoid m) Source | Since: base-4.9.0.0 |
Defined in Data.Semigroup Methods(<>) :: WrappedMonoid m -> WrappedMonoid m -> WrappedMonoid m Source sconcat :: NonEmpty (WrappedMonoid m) -> WrappedMonoid m Source stimes :: Integral b => b -> WrappedMonoid m -> WrappedMonoid m Source | |
| Semigroup a => Semigroup (Dual a) Source | Since: base-4.9.0.0 |
| Semigroup (Endo a) Source | Since: base-4.9.0.0 |
| Num a => Semigroup (Product a) Source | Since: base-4.9.0.0 |
| Num a => Semigroup (Sum a) Source | Since: base-4.9.0.0 |
| Semigroup a => Semigroup (STM a) Source | Since: base-4.17.0.0 |
| (Generic a, Semigroup (Rep a ())) => Semigroup (Generically a) Source | Since: base-4.17.0.0 |
Defined in GHC.Generics Methods(<>) :: Generically a -> Generically a -> Generically a Source sconcat :: NonEmpty (Generically a) -> Generically a Source stimes :: Integral b => b -> Generically a -> Generically a Source | |
| Semigroup p => Semigroup (Par1 p) Source | Since: base-4.12.0.0 |
| Semigroup a => Semigroup (IO a) Source | Since: base-4.10.0.0 |
| Semigroup (NonEmpty a) Source | Since: base-4.9.0.0 |
| Semigroup a => Semigroup (Maybe a) Source | Since: base-4.9.0.0 |
| Semigroup a => Semigroup (a) Source | Since: base-4.15 |
| Semigroup [a] Source | Since: base-4.9.0.0 |
| Semigroup (Either a b) Source | Since: base-4.9.0.0 |
| Semigroup a => Semigroup (Op a b) Source |
(<>) :: Op a b -> Op a b -> Op a b Op f <> Op g = Op a -> f a <> g a |
| Semigroup (Proxy s) Source | Since: base-4.9.0.0 |
| Semigroup (U1 p) Source | Since: base-4.12.0.0 |
| Semigroup (V1 p) Source | Since: base-4.12.0.0 |
| Semigroup a => Semigroup (ST s a) Source | Since: base-4.11.0.0 |
| Semigroup b => Semigroup (a -> b) Source | Since: base-4.9.0.0 |
| (Semigroup a, Semigroup b) => Semigroup (a, b) Source | Since: base-4.9.0.0 |
| Semigroup a => Semigroup (Const a b) Source | Since: base-4.9.0.0 |
| (Applicative f, Semigroup a) => Semigroup (Ap f a) Source | Since: base-4.12.0.0 |
| Alternative f => Semigroup (Alt f a) Source | Since: base-4.9.0.0 |
| Semigroup (f p) => Semigroup (Rec1 f p) Source | Since: base-4.12.0.0 |
| (Semigroup a, Semigroup b, Semigroup c) => Semigroup (a, b, c) Source | Since: base-4.9.0.0 |
| (Semigroup (f a), Semigroup (g a)) => Semigroup (Product f g a) Source | Since: base-4.16.0.0 |
| (Semigroup (f p), Semigroup (g p)) => Semigroup ((f :*: g) p) Source | Since: base-4.12.0.0 |
| Semigroup c => Semigroup (K1 i c p) Source | Since: base-4.12.0.0 |
| (Semigroup a, Semigroup b, Semigroup c, Semigroup d) => Semigroup (a, b, c, d) Source | Since: base-4.9.0.0 |
| Semigroup (f (g a)) => Semigroup (Compose f g a) Source | Since: base-4.16.0.0 |
| Semigroup (f (g p)) => Semigroup ((f :.: g) p) Source | Since: base-4.12.0.0 |
| Semigroup (f p) => Semigroup (M1 i c f p) Source | Since: base-4.12.0.0 |
| (Semigroup a, Semigroup b, Semigroup c, Semigroup d, Semigroup e) => Semigroup (a, b, c, d, e) Source | Since: base-4.9.0.0 |
class Semigroup a => Monoid a where Source
The class of monoids (types with an associative binary operation that has an identity). Instances should satisfy the following:
x <> mempty = xmempty <> x = xx <> (y <> z) = (x <> y) <> z (Semigroup law)mconcat = foldr (<>) memptyThe method names refer to the monoid of lists under concatenation, but there are many other instances.
Some types can be viewed as a monoid in more than one way, e.g. both addition and multiplication on numbers. In such cases we often define newtypes and make those instances of Monoid, e.g. Sum and Product.
NOTE: Semigroup is a superclass of Monoid since base-4.11.0.0.
Identity of mappend
>>> "Hello world" <> mempty "Hello world"
An associative operation
NOTE: This method is redundant and has the default implementation mappend = (<>) since base-4.11.0.0. Should it be implemented manually, since mappend is a synonym for (<>), it is expected that the two functions are defined the same way. In a future GHC release mappend will be removed from Monoid.
Fold a list using the monoid.
For most types, the default definition for mconcat will be used, but the function is included in the class definition so that an optimized version can be provided for specific types.
>>> mconcat ["Hello", " ", "Haskell", "!"] "Hello Haskell!"
| Monoid ByteArray Source | Since: base-4.17.0.0 |
| Monoid All Source | Since: base-2.1 |
| Monoid Any Source | Since: base-2.1 |
| Monoid Event Source | Since: base-4.4.0.0 |
| Monoid Lifetime Source |
Since: base-4.8.0.0 |
| Monoid Ordering Source | Since: base-2.1 |
| Monoid () Source | Since: base-2.1 |
| FiniteBits a => Monoid (And a) Source |
This constraint is arguably too strong. However, as some types (such as Since: base-4.16 |
| FiniteBits a => Monoid (Iff a) Source |
This constraint is arguably too strong. However, as some types (such as Since: base-4.16 |
| Bits a => Monoid (Ior a) Source | Since: base-4.16 |
| Bits a => Monoid (Xor a) Source | Since: base-4.16 |
| Monoid (Comparison a) Source |
mempty :: Comparison a mempty = Comparison _ _ -> EQ |
Defined in Data.Functor.Contravariant Methodsmempty :: Comparison a Source mappend :: Comparison a -> Comparison a -> Comparison a Source mconcat :: [Comparison a] -> Comparison a Source | |
| Monoid (Equivalence a) Source |
mempty :: Equivalence a mempty = Equivalence _ _ -> True |
Defined in Data.Functor.Contravariant Methodsmempty :: Equivalence a Source mappend :: Equivalence a -> Equivalence a -> Equivalence a Source mconcat :: [Equivalence a] -> Equivalence a Source | |
| Monoid (Predicate a) Source |
mempty :: Predicate a mempty = _ -> True |
| Monoid a => Monoid (Identity a) Source | Since: base-4.9.0.0 |
| Monoid (First a) Source | Since: base-2.1 |
| Monoid (Last a) Source | Since: base-2.1 |
| Monoid a => Monoid (Down a) Source | Since: base-4.11.0.0 |
| (Ord a, Bounded a) => Monoid (Max a) Source | Since: base-4.9.0.0 |
| (Ord a, Bounded a) => Monoid (Min a) Source | Since: base-4.9.0.0 |
| Monoid m => Monoid (WrappedMonoid m) Source | Since: base-4.9.0.0 |
Defined in Data.Semigroup Methodsmempty :: WrappedMonoid m Source mappend :: WrappedMonoid m -> WrappedMonoid m -> WrappedMonoid m Source mconcat :: [WrappedMonoid m] -> WrappedMonoid m Source | |
| Monoid a => Monoid (Dual a) Source | Since: base-2.1 |
| Monoid (Endo a) Source | Since: base-2.1 |
| Num a => Monoid (Product a) Source | Since: base-2.1 |
| Num a => Monoid (Sum a) Source | Since: base-2.1 |
| Monoid a => Monoid (STM a) Source | Since: base-4.17.0.0 |
| (Generic a, Monoid (Rep a ())) => Monoid (Generically a) Source | Since: base-4.17.0.0 |
Defined in GHC.Generics Methodsmempty :: Generically a Source mappend :: Generically a -> Generically a -> Generically a Source mconcat :: [Generically a] -> Generically a Source | |
| Monoid p => Monoid (Par1 p) Source | Since: base-4.12.0.0 |
| Monoid a => Monoid (IO a) Source | Since: base-4.9.0.0 |
| Semigroup a => Monoid (Maybe a) Source |
Lift a semigroup into Since 4.11.0: constraint on inner Since: base-2.1 |
| Monoid a => Monoid (a) Source | Since: base-4.15 |
| Monoid [a] Source | Since: base-2.1 |
| Monoid a => Monoid (Op a b) Source |
mempty :: Op a b mempty = Op _ -> mempty |
| Monoid (Proxy s) Source | Since: base-4.7.0.0 |
| Monoid (U1 p) Source | Since: base-4.12.0.0 |
| Monoid a => Monoid (ST s a) Source | Since: base-4.11.0.0 |
| Monoid b => Monoid (a -> b) Source | Since: base-2.1 |
| (Monoid a, Monoid b) => Monoid (a, b) Source | Since: base-2.1 |
| Monoid a => Monoid (Const a b) Source | Since: base-4.9.0.0 |
| (Applicative f, Monoid a) => Monoid (Ap f a) Source | Since: base-4.12.0.0 |
| Alternative f => Monoid (Alt f a) Source | Since: base-4.8.0.0 |
| Monoid (f p) => Monoid (Rec1 f p) Source | Since: base-4.12.0.0 |
| (Monoid a, Monoid b, Monoid c) => Monoid (a, b, c) Source | Since: base-2.1 |
| (Monoid (f a), Monoid (g a)) => Monoid (Product f g a) Source | Since: base-4.16.0.0 |
| (Monoid (f p), Monoid (g p)) => Monoid ((f :*: g) p) Source | Since: base-4.12.0.0 |
| Monoid c => Monoid (K1 i c p) Source | Since: base-4.12.0.0 |
| (Monoid a, Monoid b, Monoid c, Monoid d) => Monoid (a, b, c, d) Source | Since: base-2.1 |
| Monoid (f (g a)) => Monoid (Compose f g a) Source | Since: base-4.16.0.0 |
| Monoid (f (g p)) => Monoid ((f :.: g) p) Source | Since: base-4.12.0.0 |
| Monoid (f p) => Monoid (M1 i c f p) Source | Since: base-4.12.0.0 |
| (Monoid a, Monoid b, Monoid c, Monoid d, Monoid e) => Monoid (a, b, c, d, e) Source | Since: base-2.1 |
A type f is a Functor if it provides a function fmap which, given any types a and b lets you apply any function from (a -> b) to turn an f a into an f b, preserving the structure of f. Furthermore f needs to adhere to the following:
Note, that the second law follows from the free theorem of the type fmap and the first law, so you need only check that the former condition holds. See https://www.schoolofhaskell.com/user/edwardk/snippets/fmap or https://github.com/quchen/articles/blob/master/second_functor_law.md for an explanation.
fmap :: (a -> b) -> f a -> f b Source
fmap is used to apply a function of type (a -> b) to a value of type f a, where f is a functor, to produce a value of type f b. Note that for any type constructor with more than one parameter (e.g., Either), only the last type parameter can be modified with fmap (e.g., b in `Either a b`).
Some type constructors with two parameters or more have a Bifunctor instance that allows both the last and the penultimate parameters to be mapped over.
Convert from a Maybe Int to a Maybe String using show:
>>> fmap show Nothing Nothing >>> fmap show (Just 3) Just "3"
Convert from an Either Int Int to an Either Int String using show:
>>> fmap show (Left 17) Left 17 >>> fmap show (Right 17) Right "17"
Double each element of a list:
>>> fmap (*2) [1,2,3] [2,4,6]
Apply even to the second element of a pair:
>>> fmap even (2,2) (2,True)
It may seem surprising that the function is only applied to the last element of the tuple compared to the list example above which applies it to every element in the list. To understand, remember that tuples are type constructors with multiple type parameters: a tuple of 3 elements (a,b,c) can also be written (,,) a b c and its Functor instance is defined for Functor ((,,) a b) (i.e., only the third parameter is free to be mapped over with fmap).
It explains why fmap can be used with tuples containing values of different types as in the following example:
>>> fmap even ("hello", 1.0, 4)
("hello",1.0,True)
(<$) :: a -> f b -> f a infixl 4 Source
Replace all locations in the input with the same value. The default definition is fmap . const, but this may be overridden with a more efficient version.
| Functor ZipList Source | Since: base-2.1 |
| Functor Handler Source | Since: base-4.6.0.0 |
| Functor Complex Source | Since: base-4.9.0.0 |
| Functor Identity Source | Since: base-4.8.0.0 |
| Functor First Source | Since: base-4.8.0.0 |
| Functor Last Source | Since: base-4.8.0.0 |
| Functor Down Source | Since: base-4.11.0.0 |
| Functor First Source | Since: base-4.9.0.0 |
| Functor Last Source | Since: base-4.9.0.0 |
| Functor Max Source | Since: base-4.9.0.0 |
| Functor Min Source | Since: base-4.9.0.0 |
| Functor Dual Source | Since: base-4.8.0.0 |
| Functor Product Source | Since: base-4.8.0.0 |
| Functor Sum Source | Since: base-4.8.0.0 |
| Functor STM Source | Since: base-4.3.0.0 |
| Functor NoIO Source | Since: base-4.8.0.0 |
| Functor Par1 Source | Since: base-4.9.0.0 |
| Functor ArgDescr Source | Since: base-4.7.0.0 |
| Functor ArgOrder Source | Since: base-4.7.0.0 |
| Functor OptDescr Source | Since: base-4.7.0.0 |
| Functor ReadP Source | Since: base-2.1 |
| Functor ReadPrec Source | Since: base-2.1 |
| Functor IO Source | Since: base-2.1 |
| Functor NonEmpty Source | Since: base-4.9.0.0 |
| Functor Maybe Source | Since: base-2.1 |
| Functor Solo Source | Since: base-4.15 |
| Functor [] Source | Since: base-2.1 |
| Monad m => Functor (WrappedMonad m) Source | Since: base-2.1 |
Defined in Control.Applicative Methodsfmap :: (a -> b) -> WrappedMonad m a -> WrappedMonad m b Source (<$) :: a -> WrappedMonad m b -> WrappedMonad m a Source | |
| Arrow a => Functor (ArrowMonad a) Source | Since: base-4.6.0.0 |
Defined in Control.Arrow Methodsfmap :: (a0 -> b) -> ArrowMonad a a0 -> ArrowMonad a b Source (<$) :: a0 -> ArrowMonad a b -> ArrowMonad a a0 Source | |
| Functor (ST s) Source | Since: base-2.1 |
| Functor (Either a) Source | Since: base-3.0 |
| Functor (Proxy :: Type -> Type) Source | Since: base-4.7.0.0 |
| Functor (Arg a) Source | Since: base-4.9.0.0 |
| Functor (Array i) Source | Since: base-2.1 |
| Functor (U1 :: Type -> Type) Source | Since: base-4.9.0.0 |
| Functor (V1 :: Type -> Type) Source | Since: base-4.9.0.0 |
| Functor (ST s) Source | Since: base-2.1 |
| Functor ((,) a) Source | Since: base-2.1 |
| Arrow a => Functor (WrappedArrow a b) Source | Since: base-2.1 |
Defined in Control.Applicative Methodsfmap :: (a0 -> b0) -> WrappedArrow a b a0 -> WrappedArrow a b b0 Source (<$) :: a0 -> WrappedArrow a b b0 -> WrappedArrow a b a0 Source | |
| Functor m => Functor (Kleisli m a) Source | Since: base-4.14.0.0 |
| Functor (Const m :: Type -> Type) Source | Since: base-2.1 |
| Functor f => Functor (Ap f) Source | Since: base-4.12.0.0 |
| Functor f => Functor (Alt f) Source | Since: base-4.8.0.0 |
| (Generic1 f, Functor (Rep1 f)) => Functor (Generically1 f) Source | Since: base-4.17.0.0 |
Defined in GHC.Generics Methodsfmap :: (a -> b) -> Generically1 f a -> Generically1 f b Source (<$) :: a -> Generically1 f b -> Generically1 f a Source | |
| Functor f => Functor (Rec1 f) Source | Since: base-4.9.0.0 |
| Functor (URec (Ptr ()) :: Type -> Type) Source | Since: base-4.9.0.0 |
| Functor (URec Char :: Type -> Type) Source | Since: base-4.9.0.0 |
| Functor (URec Double :: Type -> Type) Source | Since: base-4.9.0.0 |
| Functor (URec Float :: Type -> Type) Source | Since: base-4.9.0.0 |
| Functor (URec Int :: Type -> Type) Source | Since: base-4.9.0.0 |
| Functor (URec Word :: Type -> Type) Source | Since: base-4.9.0.0 |
| Functor ((,,) a b) Source | Since: base-4.14.0.0 |
| (Functor f, Functor g) => Functor (Product f g) Source | Since: base-4.9.0.0 |
| (Functor f, Functor g) => Functor (Sum f g) Source | Since: base-4.9.0.0 |
| (Functor f, Functor g) => Functor (f :*: g) Source | Since: base-4.9.0.0 |
| (Functor f, Functor g) => Functor (f :+: g) Source | Since: base-4.9.0.0 |
| Functor (K1 i c :: Type -> Type) Source | Since: base-4.9.0.0 |
| Functor ((,,,) a b c) Source | Since: base-4.14.0.0 |
| Functor ((->) r) Source | Since: base-2.1 |
| (Functor f, Functor g) => Functor (Compose f g) Source | Since: base-4.9.0.0 |
| (Functor f, Functor g) => Functor (f :.: g) Source | Since: base-4.9.0.0 |
| Functor f => Functor (M1 i c f) Source | Since: base-4.9.0.0 |
(<$>) :: Functor f => (a -> b) -> f a -> f b infixl 4 Source
An infix synonym for fmap.
The name of this operator is an allusion to $. Note the similarities between their types:
($) :: (a -> b) -> a -> b (<$>) :: Functor f => (a -> b) -> f a -> f b
Whereas $ is function application, <$> is function application lifted over a Functor.
Convert from a Maybe Int to a Maybe
String using show:
>>> show <$> Nothing Nothing >>> show <$> Just 3 Just "3"
Convert from an Either Int Int to an Either Int String using show:
>>> show <$> Left 17 Left 17 >>> show <$> Right 17 Right "17"
Double each element of a list:
>>> (*2) <$> [1,2,3] [2,4,6]
Apply even to the second element of a pair:
>>> even <$> (2,2) (2,True)
class Functor f => Applicative f where Source
A functor with application, providing operations to
pure), and<*> and liftA2).A minimal complete definition must include implementations of pure and of either <*> or liftA2. If it defines both, then they must behave the same as their default definitions:
(<*>) = liftA2 id
liftA2 f x y = f <$> x <*> y
Further, any definition must satisfy the following:
pure id <*> v = v
pure (.) <*> u <*> v <*> w = u <*> (v <*> w)
pure f <*> pure x = pure (f x)
u <*> pure y = pure ($ y) <*> u
The other methods have the following default definitions, which may be overridden with equivalent specialized implementations:
As a consequence of these laws, the Functor instance for f will satisfy
It may be useful to note that supposing
forall x y. p (q x y) = f x . g y
it follows from the above that
liftA2 p (liftA2 q u v) = liftA2 f u . liftA2 g v
If f is also a Monad, it should satisfy
(which implies that pure and <*> satisfy the applicative functor laws).
Lift a value.
(<*>) :: f (a -> b) -> f a -> f b infixl 4 Source
Sequential application.
A few functors support an implementation of <*> that is more efficient than the default one.
Used in combination with (<$>), (<*>) can be used to build a record.
>>> data MyState = MyState {arg1 :: Foo, arg2 :: Bar, arg3 :: Baz}
>>> produceFoo :: Applicative f => f Foo
>>> produceBar :: Applicative f => f Bar >>> produceBaz :: Applicative f => f Baz
>>> mkState :: Applicative f => f MyState >>> mkState = MyState <$> produceFoo <*> produceBar <*> produceBaz
(*>) :: f a -> f b -> f b infixl 4 Source
Sequence actions, discarding the value of the first argument.
If used in conjunction with the Applicative instance for Maybe, you can chain Maybe computations, with a possible "early return" in case of Nothing.
>>> Just 2 *> Just 3 Just 3
>>> Nothing *> Just 3 Nothing
Of course a more interesting use case would be to have effectful computations instead of just returning pure values.
>>> import Data.Char
>>> import Text.ParserCombinators.ReadP
>>> let p = string "my name is " *> munch1 isAlpha <* eof
>>> readP_to_S p "my name is Simon"
[("Simon","")]
(<*) :: f a -> f b -> f a infixl 4 Source
Sequence actions, discarding the value of the second argument.
| Applicative ZipList Source |
f <$> ZipList xs1 <*> ... <*> ZipList xsN
= ZipList (zipWithN f xs1 ... xsN)
where (\a b c -> stimes c [a, b]) <$> ZipList "abcd" <*> ZipList "567" <*> ZipList [1..]
= ZipList (zipWith3 (\a b c -> stimes c [a, b]) "abcd" "567" [1..])
= ZipList {getZipList = ["a5","b6b6","c7c7c7"]}
Since: base-2.1 |
| Applicative Complex Source | Since: base-4.9.0.0 |
| Applicative Identity Source | Since: base-4.8.0.0 |
Defined in Data.Functor.Identity | |
| Applicative First Source | Since: base-4.8.0.0 |
| Applicative Last Source | Since: base-4.8.0.0 |
| Applicative Down Source | Since: base-4.11.0.0 |
| Applicative First Source | Since: base-4.9.0.0 |
| Applicative Last Source | Since: base-4.9.0.0 |
| Applicative Max Source | Since: base-4.9.0.0 |
| Applicative Min Source | Since: base-4.9.0.0 |
| Applicative Dual Source | Since: base-4.8.0.0 |
| Applicative Product Source | Since: base-4.8.0.0 |
Defined in Data.Semigroup.Internal | |
| Applicative Sum Source | Since: base-4.8.0.0 |
| Applicative STM Source | Since: base-4.8.0.0 |
| Applicative NoIO Source | Since: base-4.8.0.0 |
| Applicative Par1 Source | Since: base-4.9.0.0 |
| Applicative ReadP Source | Since: base-4.6.0.0 |
| Applicative ReadPrec Source | Since: base-4.6.0.0 |
Defined in Text.ParserCombinators.ReadPrec | |
| Applicative IO Source | Since: base-2.1 |
| Applicative NonEmpty Source | Since: base-4.9.0.0 |
Defined in GHC.Base | |
| Applicative Maybe Source | Since: base-2.1 |
| Applicative Solo Source | Since: base-4.15 |
| Applicative [] Source | Since: base-2.1 |
| Monad m => Applicative (WrappedMonad m) Source | Since: base-2.1 |
Defined in Control.Applicative Methodspure :: a -> WrappedMonad m a Source (<*>) :: WrappedMonad m (a -> b) -> WrappedMonad m a -> WrappedMonad m b Source liftA2 :: (a -> b -> c) -> WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m c Source (*>) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m b Source (<*) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m a Source | |
| Arrow a => Applicative (ArrowMonad a) Source | Since: base-4.6.0.0 |
Defined in Control.Arrow Methodspure :: a0 -> ArrowMonad a a0 Source (<*>) :: ArrowMonad a (a0 -> b) -> ArrowMonad a a0 -> ArrowMonad a b Source liftA2 :: (a0 -> b -> c) -> ArrowMonad a a0 -> ArrowMonad a b -> ArrowMonad a c Source (*>) :: ArrowMonad a a0 -> ArrowMonad a b -> ArrowMonad a b Source (<*) :: ArrowMonad a a0 -> ArrowMonad a b -> ArrowMonad a a0 Source | |
| Applicative (ST s) Source | Since: base-2.1 |
| Applicative (Either e) Source | Since: base-3.0 |
Defined in Data.Either | |
| Applicative (Proxy :: Type -> Type) Source | Since: base-4.7.0.0 |
| Applicative (U1 :: Type -> Type) Source | Since: base-4.9.0.0 |
| Applicative (ST s) Source | Since: base-4.4.0.0 |
| Monoid a => Applicative ((,) a) Source |
For tuples, the ("hello ", (+15)) <*> ("world!", 2002)
("hello world!",2017)
Since: base-2.1 |
| Arrow a => Applicative (WrappedArrow a b) Source | Since: base-2.1 |
Defined in Control.Applicative Methodspure :: a0 -> WrappedArrow a b a0 Source (<*>) :: WrappedArrow a b (a0 -> b0) -> WrappedArrow a b a0 -> WrappedArrow a b b0 Source liftA2 :: (a0 -> b0 -> c) -> WrappedArrow a b a0 -> WrappedArrow a b b0 -> WrappedArrow a b c Source (*>) :: WrappedArrow a b a0 -> WrappedArrow a b b0 -> WrappedArrow a b b0 Source (<*) :: WrappedArrow a b a0 -> WrappedArrow a b b0 -> WrappedArrow a b a0 Source | |
| Applicative m => Applicative (Kleisli m a) Source | Since: base-4.14.0.0 |
Defined in Control.Arrow Methodspure :: a0 -> Kleisli m a a0 Source (<*>) :: Kleisli m a (a0 -> b) -> Kleisli m a a0 -> Kleisli m a b Source liftA2 :: (a0 -> b -> c) -> Kleisli m a a0 -> Kleisli m a b -> Kleisli m a c Source (*>) :: Kleisli m a a0 -> Kleisli m a b -> Kleisli m a b Source (<*) :: Kleisli m a a0 -> Kleisli m a b -> Kleisli m a a0 Source | |
| Monoid m => Applicative (Const m :: Type -> Type) Source | Since: base-2.0.1 |
| Applicative f => Applicative (Ap f) Source | Since: base-4.12.0.0 |
| Applicative f => Applicative (Alt f) Source | Since: base-4.8.0.0 |
| (Generic1 f, Applicative (Rep1 f)) => Applicative (Generically1 f) Source | Since: base-4.17.0.0 |
Defined in GHC.Generics Methodspure :: a -> Generically1 f a Source (<*>) :: Generically1 f (a -> b) -> Generically1 f a -> Generically1 f b Source liftA2 :: (a -> b -> c) -> Generically1 f a -> Generically1 f b -> Generically1 f c Source (*>) :: Generically1 f a -> Generically1 f b -> Generically1 f b Source (<*) :: Generically1 f a -> Generically1 f b -> Generically1 f a Source | |
| Applicative f => Applicative (Rec1 f) Source | Since: base-4.9.0.0 |
| (Monoid a, Monoid b) => Applicative ((,,) a b) Source | Since: base-4.14.0.0 |
Defined in GHC.Base | |
| (Applicative f, Applicative g) => Applicative (Product f g) Source | Since: base-4.9.0.0 |
Defined in Data.Functor.Product Methodspure :: a -> Product f g a Source (<*>) :: Product f g (a -> b) -> Product f g a -> Product f g b Source liftA2 :: (a -> b -> c) -> Product f g a -> Product f g b -> Product f g c Source (*>) :: Product f g a -> Product f g b -> Product f g b Source (<*) :: Product f g a -> Product f g b -> Product f g a Source | |
| (Applicative f, Applicative g) => Applicative (f :*: g) Source | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
| Monoid c => Applicative (K1 i c :: Type -> Type) Source | Since: base-4.12.0.0 |
| (Monoid a, Monoid b, Monoid c) => Applicative ((,,,) a b c) Source | Since: base-4.14.0.0 |
Defined in GHC.Base Methodspure :: a0 -> (a, b, c, a0) Source (<*>) :: (a, b, c, a0 -> b0) -> (a, b, c, a0) -> (a, b, c, b0) Source liftA2 :: (a0 -> b0 -> c0) -> (a, b, c, a0) -> (a, b, c, b0) -> (a, b, c, c0) Source (*>) :: (a, b, c, a0) -> (a, b, c, b0) -> (a, b, c, b0) Source (<*) :: (a, b, c, a0) -> (a, b, c, b0) -> (a, b, c, a0) Source | |
| Applicative ((->) r) Source | Since: base-2.1 |
| (Applicative f, Applicative g) => Applicative (Compose f g) Source | Since: base-4.9.0.0 |
Defined in Data.Functor.Compose Methodspure :: a -> Compose f g a Source (<*>) :: Compose f g (a -> b) -> Compose f g a -> Compose f g b Source liftA2 :: (a -> b -> c) -> Compose f g a -> Compose f g b -> Compose f g c Source (*>) :: Compose f g a -> Compose f g b -> Compose f g b Source (<*) :: Compose f g a -> Compose f g b -> Compose f g a Source | |
| (Applicative f, Applicative g) => Applicative (f :.: g) Source | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
| Applicative f => Applicative (M1 i c f) Source | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
class Applicative m => Monad m where Source
The Monad class defines the basic operations over a monad, a concept from a branch of mathematics known as category theory. From the perspective of a Haskell programmer, however, it is best to think of a monad as an abstract datatype of actions. Haskell's do expressions provide a convenient syntax for writing monadic expressions.
Instances of Monad should satisfy the following:
return a >>= k = k am >>= return = mm >>= (\x -> k x >>= h) = (m >>= k) >>= hFurthermore, the Monad and Applicative operations should relate as follows:
The above laws imply:
and that pure and (<*>) satisfy the applicative functor laws.
The instances of Monad for lists, Maybe and IO defined in the Prelude satisfy these laws.
(>>=) :: forall a b. m a -> (a -> m b) -> m b infixl 1 Source
Sequentially compose two actions, passing any value produced by the first as an argument to the second.
'as >>= bs' can be understood as the do expression
do a <- as bs a
(>>) :: forall a b. m a -> m b -> m b infixl 1 Source
Sequentially compose two actions, discarding any value produced by the first, like sequencing operators (such as the semicolon) in imperative languages.
'as >> bs' can be understood as the do expression
do as bs
Inject a value into the monadic type.
| Monad Complex Source | Since: base-4.9.0.0 |
| Monad Identity Source | Since: base-4.8.0.0 |
| Monad First Source | Since: base-4.8.0.0 |
| Monad Last Source | Since: base-4.8.0.0 |
| Monad Down Source | Since: base-4.11.0.0 |
| Monad First Source | Since: base-4.9.0.0 |
| Monad Last Source | Since: base-4.9.0.0 |
| Monad Max Source | Since: base-4.9.0.0 |
| Monad Min Source | Since: base-4.9.0.0 |
| Monad Dual Source | Since: base-4.8.0.0 |
| Monad Product Source | Since: base-4.8.0.0 |
| Monad Sum Source | Since: base-4.8.0.0 |
| Monad STM Source | Since: base-4.3.0.0 |
| Monad NoIO Source | Since: base-4.4.0.0 |
| Monad Par1 Source | Since: base-4.9.0.0 |
| Monad ReadP Source | Since: base-2.1 |
| Monad ReadPrec Source | Since: base-2.1 |
| Monad IO Source | Since: base-2.1 |
| Monad NonEmpty Source | Since: base-4.9.0.0 |
| Monad Maybe Source | Since: base-2.1 |
| Monad Solo Source | Since: base-4.15 |
| Monad [] Source | Since: base-2.1 |
| Monad m => Monad (WrappedMonad m) Source | Since: base-4.7.0.0 |
Defined in Control.Applicative Methods(>>=) :: WrappedMonad m a -> (a -> WrappedMonad m b) -> WrappedMonad m b Source (>>) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m b Source return :: a -> WrappedMonad m a Source | |
| ArrowApply a => Monad (ArrowMonad a) Source | Since: base-2.1 |
Defined in Control.Arrow Methods(>>=) :: ArrowMonad a a0 -> (a0 -> ArrowMonad a b) -> ArrowMonad a b Source (>>) :: ArrowMonad a a0 -> ArrowMonad a b -> ArrowMonad a b Source return :: a0 -> ArrowMonad a a0 Source | |
| Monad (ST s) Source | Since: base-2.1 |
| Monad (Either e) Source | Since: base-4.4.0.0 |
| Monad (Proxy :: Type -> Type) Source | Since: base-4.7.0.0 |
| Monad (U1 :: Type -> Type) Source | Since: base-4.9.0.0 |
| Monad (ST s) Source | Since: base-2.1 |
| Monoid a => Monad ((,) a) Source | Since: base-4.9.0.0 |
| Monad m => Monad (Kleisli m a) Source | Since: base-4.14.0.0 |
| Monad f => Monad (Ap f) Source | Since: base-4.12.0.0 |
| Monad f => Monad (Alt f) Source | Since: base-4.8.0.0 |
| Monad f => Monad (Rec1 f) Source | Since: base-4.9.0.0 |
| (Monoid a, Monoid b) => Monad ((,,) a b) Source | Since: base-4.14.0.0 |
| (Monad f, Monad g) => Monad (Product f g) Source | Since: base-4.9.0.0 |
| (Monad f, Monad g) => Monad (f :*: g) Source | Since: base-4.9.0.0 |
| (Monoid a, Monoid b, Monoid c) => Monad ((,,,) a b c) Source | Since: base-4.14.0.0 |
| Monad ((->) r) Source | Since: base-2.1 |
| Monad f => Monad (M1 i c f) Source | Since: base-4.9.0.0 |
class Monad m => MonadFail m where Source
When a value is bound in do-notation, the pattern on the left hand side of <- might not match. In this case, this class provides a function to recover.
A Monad without a MonadFail instance may only be used in conjunction with pattern that always match, such as newtypes, tuples, data types with only a single data constructor, and irrefutable patterns (~pat).
Instances of MonadFail should satisfy the following law: fail s should be a left zero for >>=,
fail s >>= f = fail s
If your Monad is also MonadPlus, a popular definition is
fail _ = mzero
Since: base-4.9.0.0
| MonadFail ReadP Source | Since: base-4.9.0.0 |
Defined in Text.ParserCombinators.ReadP | |
| MonadFail ReadPrec Source | Since: base-4.9.0.0 |
Defined in Text.ParserCombinators.ReadPrec | |
| MonadFail IO Source | Since: base-4.9.0.0 |
Defined in Control.Monad.Fail | |
| MonadFail Maybe Source | Since: base-4.9.0.0 |
Defined in Control.Monad.Fail | |
| MonadFail [] Source | Since: base-4.9.0.0 |
Defined in Control.Monad.Fail | |
| MonadFail f => MonadFail (Ap f) Source | Since: base-4.12.0.0 |
Defined in Data.Monoid | |
mapM_ :: (Foldable t, Monad m) => (a -> m b) -> t a -> m () Source
Map each element of a structure to a monadic action, evaluate these actions from left to right, and ignore the results. For a version that doesn't ignore the results see mapM.
mapM_ is just like traverse_, but specialised to monadic actions.
sequence_ :: (Foldable t, Monad m) => t (m a) -> m () Source
Evaluate each monadic action in the structure from left to right, and ignore the results. For a version that doesn't ignore the results see sequence.
sequence_ is just like sequenceA_, but specialised to monadic actions.
(=<<) :: Monad m => (a -> m b) -> m a -> m b infixr 1 Source
Same as >>=, but with the arguments interchanged.
The Foldable class represents data structures that can be reduced to a summary value one element at a time. Strict left-associative folds are a good fit for space-efficient reduction, while lazy right-associative folds are a good fit for corecursive iteration, or for folds that short-circuit after processing an initial subsequence of the structure's elements.
Instances can be derived automatically by enabling the DeriveFoldable extension. For example, a derived instance for a binary tree might be:
{-# LANGUAGE DeriveFoldable #-}
data Tree a = Empty
| Leaf a
| Node (Tree a) a (Tree a)
deriving Foldable
A more detailed description can be found in the Overview section of Data.Foldable.
For the class laws see the Laws section of Data.Foldable.
foldMap :: Monoid m => (a -> m) -> t a -> m Source
Map each element of the structure into a monoid, and combine the results with (<>). This fold is right-associative and lazy in the accumulator. For strict left-associative folds consider foldMap' instead.
Basic usage:
>>> foldMap Sum [1, 3, 5]
Sum {getSum = 9}
>>> foldMap Product [1, 3, 5]
Product {getProduct = 15}
>>> foldMap (replicate 3) [1, 2, 3] [1,1,1,2,2,2,3,3,3]
When a Monoid's (<>) is lazy in its second argument, foldMap can return a result even from an unbounded structure. For example, lazy accumulation enables Data.ByteString.Builder to efficiently serialise large data structures and produce the output incrementally:
>>> import qualified Data.ByteString.Lazy as L >>> import qualified Data.ByteString.Builder as B >>> let bld :: Int -> B.Builder; bld i = B.intDec i <> B.word8 0x20 >>> let lbs = B.toLazyByteString $ foldMap bld [0..] >>> L.take 64 lbs "0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24"
foldr :: (a -> b -> b) -> b -> t a -> b Source
Right-associative fold of a structure, lazy in the accumulator.
In the case of lists, foldr, when applied to a binary operator, a starting value (typically the right-identity of the operator), and a list, reduces the list using the binary operator, from right to left:
foldr f z [x1, x2, ..., xn] == x1 `f` (x2 `f` ... (xn `f` z)...)
Note that since the head of the resulting expression is produced by an application of the operator to the first element of the list, given an operator lazy in its right argument, foldr can produce a terminating expression from an unbounded list.
For a general Foldable structure this should be semantically identical to,
foldr f z = foldr f z . toList
Basic usage:
>>> foldr (||) False [False, True, False] True
>>> foldr (||) False [] False
>>> foldr (\c acc -> acc ++ [c]) "foo" ['a', 'b', 'c', 'd'] "foodcba"
⚠️ Applying foldr to infinite structures usually doesn't terminate.
It may still terminate under one of the following conditions:
(||) short-circuits on True values, so the following terminates because there is a True value finitely far from the left side:
>>> foldr (||) False (True : repeat False) True
But the following doesn't terminate:
>>> foldr (||) False (repeat False ++ [True]) * Hangs forever *
Applying foldr to infinite structures terminates when the operator is lazy in its second argument (the initial accumulator is never used in this case, and so could be left undefined, but [] is more clear):
>>> take 5 $ foldr (\i acc -> i : fmap (+3) acc) [] (repeat 1) [1,4,7,10,13]
foldl :: (b -> a -> b) -> b -> t a -> b Source
Left-associative fold of a structure, lazy in the accumulator. This is rarely what you want, but can work well for structures with efficient right-to-left sequencing and an operator that is lazy in its left argument.
In the case of lists, foldl, when applied to a binary operator, a starting value (typically the left-identity of the operator), and a list, reduces the list using the binary operator, from left to right:
foldl f z [x1, x2, ..., xn] == (...((z `f` x1) `f` x2) `f`...) `f` xn
Note that to produce the outermost application of the operator the entire input list must be traversed. Like all left-associative folds, foldl will diverge if given an infinite list.
If you want an efficient strict left-fold, you probably want to use foldl' instead of foldl. The reason for this is that the latter does not force the inner results (e.g. z `f` x1 in the above example) before applying them to the operator (e.g. to (`f` x2)). This results in a thunk chain O(n) elements long, which then must be evaluated from the outside-in.
For a general Foldable structure this should be semantically identical to:
foldl f z = foldl f z . toList
The first example is a strict fold, which in practice is best performed with foldl'.
>>> foldl (+) 42 [1,2,3,4] 52
Though the result below is lazy, the input is reversed before prepending it to the initial accumulator, so corecursion begins only after traversing the entire input string.
>>> foldl (\acc c -> c : acc) "abcd" "efgh" "hgfeabcd"
A left fold of a structure that is infinite on the right cannot terminate, even when for any finite input the fold just returns the initial accumulator:
>>> foldl (\a _ -> a) 0 $ repeat 1 * Hangs forever *
WARNING: When it comes to lists, you always want to use either foldl' or foldr instead.
foldr1 :: (a -> a -> a) -> t a -> a Source
A variant of foldr that has no base case, and thus may only be applied to non-empty structures.
This function is non-total and will raise a runtime exception if the structure happens to be empty.
Basic usage:
>>> foldr1 (+) [1..4] 10
>>> foldr1 (+) [] Exception: Prelude.foldr1: empty list
>>> foldr1 (+) Nothing *** Exception: foldr1: empty structure
>>> foldr1 (-) [1..4] -2
>>> foldr1 (&&) [True, False, True, True] False
>>> foldr1 (||) [False, False, True, True] True
>>> foldr1 (+) [1..] * Hangs forever *
foldl1 :: (a -> a -> a) -> t a -> a Source
A variant of foldl that has no base case, and thus may only be applied to non-empty structures.
This function is non-total and will raise a runtime exception if the structure happens to be empty.
foldl1 f = foldl1 f . toList
Basic usage:
>>> foldl1 (+) [1..4] 10
>>> foldl1 (+) [] *** Exception: Prelude.foldl1: empty list
>>> foldl1 (+) Nothing *** Exception: foldl1: empty structure
>>> foldl1 (-) [1..4] -8
>>> foldl1 (&&) [True, False, True, True] False
>>> foldl1 (||) [False, False, True, True] True
>>> foldl1 (+) [1..] * Hangs forever *
elem :: Eq a => a -> t a -> Bool infix 4 Source
Does the element occur in the structure?
Note: elem is often used in infix form.
Basic usage:
>>> 3 `elem` [] False
>>> 3 `elem` [1,2] False
>>> 3 `elem` [1,2,3,4,5] True
For infinite structures, the default implementation of elem terminates if the sought-after value exists at a finite distance from the left side of the structure:
>>> 3 `elem` [1..] True
>>> 3 `elem` ([4..] ++ [3]) * Hangs forever *
Since: base-4.8.0.0
maximum :: forall a. Ord a => t a -> a Source
The largest element of a non-empty structure.
This function is non-total and will raise a runtime exception if the structure happens to be empty. A structure that supports random access and maintains its elements in order should provide a specialised implementation to return the maximum in faster than linear time.
Basic usage:
>>> maximum [1..10] 10
>>> maximum [] *** Exception: Prelude.maximum: empty list
>>> maximum Nothing *** Exception: maximum: empty structure
WARNING: This function is partial for possibly-empty structures like lists.
Since: base-4.8.0.0
minimum :: forall a. Ord a => t a -> a Source
The least element of a non-empty structure.
This function is non-total and will raise a runtime exception if the structure happens to be empty. A structure that supports random access and maintains its elements in order should provide a specialised implementation to return the minimum in faster than linear time.
Basic usage:
>>> minimum [1..10] 1
>>> minimum [] *** Exception: Prelude.minimum: empty list
>>> minimum Nothing *** Exception: minimum: empty structure
WARNING: This function is partial for possibly-empty structures like lists.
Since: base-4.8.0.0
sum :: Num a => t a -> a Source
The sum function computes the sum of the numbers of a structure.
Basic usage:
>>> sum [] 0
>>> sum [42] 42
>>> sum [1..10] 55
>>> sum [4.1, 2.0, 1.7] 7.8
>>> sum [1..] * Hangs forever *
Since: base-4.8.0.0
product :: Num a => t a -> a Source
The product function computes the product of the numbers of a structure.
Basic usage:
>>> product [] 1
>>> product [42] 42
>>> product [1..10] 3628800
>>> product [4.1, 2.0, 1.7] 13.939999999999998
>>> product [1..] * Hangs forever *
Since: base-4.8.0.0
| Foldable ZipList Source | Since: base-4.9.0.0 |
Defined in Control.Applicative Methodsfold :: Monoid m => ZipList m -> m Source foldMap :: Monoid m => (a -> m) -> ZipList a -> m Source foldMap' :: Monoid m => (a -> m) -> ZipList a -> m Source foldr :: (a -> b -> b) -> b -> ZipList a -> b Source foldr' :: (a -> b -> b) -> b -> ZipList a -> b Source foldl :: (b -> a -> b) -> b -> ZipList a -> b Source foldl' :: (b -> a -> b) -> b -> ZipList a -> b Source foldr1 :: (a -> a -> a) -> ZipList a -> a Source foldl1 :: (a -> a -> a) -> ZipList a -> a Source toList :: ZipList a -> [a] Source null :: ZipList a -> Bool Source length :: ZipList a -> Int Source elem :: Eq a => a -> ZipList a -> Bool Source maximum :: Ord a => ZipList a -> a Source minimum :: Ord a => ZipList a -> a Source | |
| Foldable Complex Source | Since: base-4.9.0.0 |
Defined in Data.Complex Methodsfold :: Monoid m => Complex m -> m Source foldMap :: Monoid m => (a -> m) -> Complex a -> m Source foldMap' :: Monoid m => (a -> m) -> Complex a -> m Source foldr :: (a -> b -> b) -> b -> Complex a -> b Source foldr' :: (a -> b -> b) -> b -> Complex a -> b Source foldl :: (b -> a -> b) -> b -> Complex a -> b Source foldl' :: (b -> a -> b) -> b -> Complex a -> b Source foldr1 :: (a -> a -> a) -> Complex a -> a Source foldl1 :: (a -> a -> a) -> Complex a -> a Source toList :: Complex a -> [a] Source null :: Complex a -> Bool Source length :: Complex a -> Int Source elem :: Eq a => a -> Complex a -> Bool Source maximum :: Ord a => Complex a -> a Source minimum :: Ord a => Complex a -> a Source | |
| Foldable Identity Source | Since: base-4.8.0.0 |
Defined in Data.Functor.Identity Methodsfold :: Monoid m => Identity m -> m Source foldMap :: Monoid m => (a -> m) -> Identity a -> m Source foldMap' :: Monoid m => (a -> m) -> Identity a -> m Source foldr :: (a -> b -> b) -> b -> Identity a -> b Source foldr' :: (a -> b -> b) -> b -> Identity a -> b Source foldl :: (b -> a -> b) -> b -> Identity a -> b Source foldl' :: (b -> a -> b) -> b -> Identity a -> b Source foldr1 :: (a -> a -> a) -> Identity a -> a Source foldl1 :: (a -> a -> a) -> Identity a -> a Source toList :: Identity a -> [a] Source null :: Identity a -> Bool Source length :: Identity a -> Int Source elem :: Eq a => a -> Identity a -> Bool Source maximum :: Ord a => Identity a -> a Source minimum :: Ord a => Identity a -> a Source | |
| Foldable First Source | Since: base-4.8.0.0 |
Defined in Data.Foldable Methodsfold :: Monoid m => First m -> m Source foldMap :: Monoid m => (a -> m) -> First a -> m Source foldMap' :: Monoid m => (a -> m) -> First a -> m Source foldr :: (a -> b -> b) -> b -> First a -> b Source foldr' :: (a -> b -> b) -> b -> First a -> b Source foldl :: (b -> a -> b) -> b -> First a -> b Source foldl' :: (b -> a -> b) -> b -> First a -> b Source foldr1 :: (a -> a -> a) -> First a -> a Source foldl1 :: (a -> a -> a) -> First a -> a Source toList :: First a -> [a] Source null :: First a -> Bool Source length :: First a -> Int Source elem :: Eq a => a -> First a -> Bool Source maximum :: Ord a => First a -> a Source minimum :: Ord a => First a -> a Source | |
| Foldable Last Source | Since: base-4.8.0.0 |
Defined in Data.Foldable Methodsfold :: Monoid m => Last m -> m Source foldMap :: Monoid m => (a -> m) -> Last a -> m Source foldMap' :: Monoid m => (a -> m) -> Last a -> m Source foldr :: (a -> b -> b) -> b -> Last a -> b Source foldr' :: (a -> b -> b) -> b -> Last a -> b Source foldl :: (b -> a -> b) -> b -> Last a -> b Source foldl' :: (b -> a -> b) -> b -> Last a -> b Source foldr1 :: (a -> a -> a) -> Last a -> a Source foldl1 :: (a -> a -> a) -> Last a -> a Source toList :: Last a -> [a] Source length :: Last a -> Int Source elem :: Eq a => a -> Last a -> Bool Source maximum :: Ord a => Last a -> a Source minimum :: Ord a => Last a -> a Source | |
| Foldable Down Source | Since: base-4.12.0.0 |
Defined in Data.Foldable Methodsfold :: Monoid m => Down m -> m Source foldMap :: Monoid m => (a -> m) -> Down a -> m Source foldMap' :: Monoid m => (a -> m) -> Down a -> m Source foldr :: (a -> b -> b) -> b -> Down a -> b Source foldr' :: (a -> b -> b) -> b -> Down a -> b Source foldl :: (b -> a -> b) -> b -> Down a -> b Source foldl' :: (b -> a -> b) -> b -> Down a -> b Source foldr1 :: (a -> a -> a) -> Down a -> a Source foldl1 :: (a -> a -> a) -> Down a -> a Source toList :: Down a -> [a] Source length :: Down a -> Int Source elem :: Eq a => a -> Down a -> Bool Source maximum :: Ord a => Down a -> a Source minimum :: Ord a => Down a -> a Source | |
| Foldable First Source | Since: base-4.9.0.0 |
Defined in Data.Semigroup Methodsfold :: Monoid m => First m -> m Source foldMap :: Monoid m => (a -> m) -> First a -> m Source foldMap' :: Monoid m => (a -> m) -> First a -> m Source foldr :: (a -> b -> b) -> b -> First a -> b Source foldr' :: (a -> b -> b) -> b -> First a -> b Source foldl :: (b -> a -> b) -> b -> First a -> b Source foldl' :: (b -> a -> b) -> b -> First a -> b Source foldr1 :: (a -> a -> a) -> First a -> a Source foldl1 :: (a -> a -> a) -> First a -> a Source toList :: First a -> [a] Source null :: First a -> Bool Source length :: First a -> Int Source elem :: Eq a => a -> First a -> Bool Source maximum :: Ord a => First a -> a Source minimum :: Ord a => First a -> a Source | |
| Foldable Last Source | Since: base-4.9.0.0 |
Defined in Data.Semigroup Methodsfold :: Monoid m => Last m -> m Source foldMap :: Monoid m => (a -> m) -> Last a -> m Source foldMap' :: Monoid m => (a -> m) -> Last a -> m Source foldr :: (a -> b -> b) -> b -> Last a -> b Source foldr' :: (a -> b -> b) -> b -> Last a -> b Source foldl :: (b -> a -> b) -> b -> Last a -> b Source foldl' :: (b -> a -> b) -> b -> Last a -> b Source foldr1 :: (a -> a -> a) -> Last a -> a Source foldl1 :: (a -> a -> a) -> Last a -> a Source toList :: Last a -> [a] Source length :: Last a -> Int Source elem :: Eq a => a -> Last a -> Bool Source maximum :: Ord a => Last a -> a Source minimum :: Ord a => Last a -> a Source | |
| Foldable Max Source | Since: base-4.9.0.0 |
Defined in Data.Semigroup Methodsfold :: Monoid m => Max m -> m Source foldMap :: Monoid m => (a -> m) -> Max a -> m Source foldMap' :: Monoid m => (a -> m) -> Max a -> m Source foldr :: (a -> b -> b) -> b -> Max a -> b Source foldr' :: (a -> b -> b) -> b -> Max a -> b Source foldl :: (b -> a -> b) -> b -> Max a -> b Source foldl' :: (b -> a -> b) -> b -> Max a -> b Source foldr1 :: (a -> a -> a) -> Max a -> a Source foldl1 :: (a -> a -> a) -> Max a -> a Source elem :: Eq a => a -> Max a -> Bool Source maximum :: Ord a => Max a -> a Source minimum :: Ord a => Max a -> a Source | |
| Foldable Min Source | Since: base-4.9.0.0 |
Defined in Data.Semigroup Methodsfold :: Monoid m => Min m -> m Source foldMap :: Monoid m => (a -> m) -> Min a -> m Source foldMap' :: Monoid m => (a -> m) -> Min a -> m Source foldr :: (a -> b -> b) -> b -> Min a -> b Source foldr' :: (a -> b -> b) -> b -> Min a -> b Source foldl :: (b -> a -> b) -> b -> Min a -> b Source foldl' :: (b -> a -> b) -> b -> Min a -> b Source foldr1 :: (a -> a -> a) -> Min a -> a Source foldl1 :: (a -> a -> a) -> Min a -> a Source elem :: Eq a => a -> Min a -> Bool Source maximum :: Ord a => Min a -> a Source minimum :: Ord a => Min a -> a Source | |
| Foldable Dual Source | Since: base-4.8.0.0 |
Defined in Data.Foldable Methodsfold :: Monoid m => Dual m -> m Source foldMap :: Monoid m => (a -> m) -> Dual a -> m Source foldMap' :: Monoid m => (a -> m) -> Dual a -> m Source foldr :: (a -> b -> b) -> b -> Dual a -> b Source foldr' :: (a -> b -> b) -> b -> Dual a -> b Source foldl :: (b -> a -> b) -> b -> Dual a -> b Source foldl' :: (b -> a -> b) -> b -> Dual a -> b Source foldr1 :: (a -> a -> a) -> Dual a -> a Source foldl1 :: (a -> a -> a) -> Dual a -> a Source toList :: Dual a -> [a] Source length :: Dual a -> Int Source elem :: Eq a => a -> Dual a -> Bool Source maximum :: Ord a => Dual a -> a Source minimum :: Ord a => Dual a -> a Source | |
| Foldable Product Source | Since: base-4.8.0.0 |
Defined in Data.Foldable Methodsfold :: Monoid m => Product m -> m Source foldMap :: Monoid m => (a -> m) -> Product a -> m Source foldMap' :: Monoid m => (a -> m) -> Product a -> m Source foldr :: (a -> b -> b) -> b -> Product a -> b Source foldr' :: (a -> b -> b) -> b -> Product a -> b Source foldl :: (b -> a -> b) -> b -> Product a -> b Source foldl' :: (b -> a -> b) -> b -> Product a -> b Source foldr1 :: (a -> a -> a) -> Product a -> a Source foldl1 :: (a -> a -> a) -> Product a -> a Source toList :: Product a -> [a] Source null :: Product a -> Bool Source length :: Product a -> Int Source elem :: Eq a => a -> Product a -> Bool Source maximum :: Ord a => Product a -> a Source minimum :: Ord a => Product a -> a Source | |
| Foldable Sum Source | Since: base-4.8.0.0 |
Defined in Data.Foldable Methodsfold :: Monoid m => Sum m -> m Source foldMap :: Monoid m => (a -> m) -> Sum a -> m Source foldMap' :: Monoid m => (a -> m) -> Sum a -> m Source foldr :: (a -> b -> b) -> b -> Sum a -> b Source foldr' :: (a -> b -> b) -> b -> Sum a -> b Source foldl :: (b -> a -> b) -> b -> Sum a -> b Source foldl' :: (b -> a -> b) -> b -> Sum a -> b Source foldr1 :: (a -> a -> a) -> Sum a -> a Source foldl1 :: (a -> a -> a) -> Sum a -> a Source elem :: Eq a => a -> Sum a -> Bool Source maximum :: Ord a => Sum a -> a Source minimum :: Ord a => Sum a -> a Source | |
| Foldable Par1 Source | Since: base-4.9.0.0 |
Defined in Data.Foldable Methodsfold :: Monoid m => Par1 m -> m Source foldMap :: Monoid m => (a -> m) -> Par1 a -> m Source foldMap' :: Monoid m => (a -> m) -> Par1 a -> m Source foldr :: (a -> b -> b) -> b -> Par1 a -> b Source foldr' :: (a -> b -> b) -> b -> Par1 a -> b Source foldl :: (b -> a -> b) -> b -> Par1 a -> b Source foldl' :: (b -> a -> b) -> b -> Par1 a -> b Source foldr1 :: (a -> a -> a) -> Par1 a -> a Source foldl1 :: (a -> a -> a) -> Par1 a -> a Source toList :: Par1 a -> [a] Source length :: Par1 a -> Int Source elem :: Eq a => a -> Par1 a -> Bool Source maximum :: Ord a => Par1 a -> a Source minimum :: Ord a => Par1 a -> a Source | |
| Foldable NonEmpty Source | Since: base-4.9.0.0 |
Defined in Data.Foldable Methodsfold :: Monoid m => NonEmpty m -> m Source foldMap :: Monoid m => (a -> m) -> NonEmpty a -> m Source foldMap' :: Monoid m => (a -> m) -> NonEmpty a -> m Source foldr :: (a -> b -> b) -> b -> NonEmpty a -> b Source foldr' :: (a -> b -> b) -> b -> NonEmpty a -> b Source foldl :: (b -> a -> b) -> b -> NonEmpty a -> b Source foldl' :: (b -> a -> b) -> b -> NonEmpty a -> b Source foldr1 :: (a -> a -> a) -> NonEmpty a -> a Source foldl1 :: (a -> a -> a) -> NonEmpty a -> a Source toList :: NonEmpty a -> [a] Source null :: NonEmpty a -> Bool Source length :: NonEmpty a -> Int Source elem :: Eq a => a -> NonEmpty a -> Bool Source maximum :: Ord a => NonEmpty a -> a Source minimum :: Ord a => NonEmpty a -> a Source | |
| Foldable Maybe Source | Since: base-2.1 |
Defined in Data.Foldable Methodsfold :: Monoid m => Maybe m -> m Source foldMap :: Monoid m => (a -> m) -> Maybe a -> m Source foldMap' :: Monoid m => (a -> m) -> Maybe a -> m Source foldr :: (a -> b -> b) -> b -> Maybe a -> b Source foldr' :: (a -> b -> b) -> b -> Maybe a -> b Source foldl :: (b -> a -> b) -> b -> Maybe a -> b Source foldl' :: (b -> a -> b) -> b -> Maybe a -> b Source foldr1 :: (a -> a -> a) -> Maybe a -> a Source foldl1 :: (a -> a -> a) -> Maybe a -> a Source toList :: Maybe a -> [a] Source null :: Maybe a -> Bool Source length :: Maybe a -> Int Source elem :: Eq a => a -> Maybe a -> Bool Source maximum :: Ord a => Maybe a -> a Source minimum :: Ord a => Maybe a -> a Source | |
| Foldable Solo Source | Since: base-4.15 |
Defined in Data.Foldable Methodsfold :: Monoid m => Solo m -> m Source foldMap :: Monoid m => (a -> m) -> Solo a -> m Source foldMap' :: Monoid m => (a -> m) -> Solo a -> m Source foldr :: (a -> b -> b) -> b -> Solo a -> b Source foldr' :: (a -> b -> b) -> b -> Solo a -> b Source foldl :: (b -> a -> b) -> b -> Solo a -> b Source foldl' :: (b -> a -> b) -> b -> Solo a -> b Source foldr1 :: (a -> a -> a) -> Solo a -> a Source foldl1 :: (a -> a -> a) -> Solo a -> a Source toList :: Solo a -> [a] Source length :: Solo a -> Int Source elem :: Eq a => a -> Solo a -> Bool Source maximum :: Ord a => Solo a -> a Source minimum :: Ord a => Solo a -> a Source | |
| Foldable [] Source | Since: base-2.1 |
Defined in Data.Foldable Methodsfold :: Monoid m => [m] -> m Source foldMap :: Monoid m => (a -> m) -> [a] -> m Source foldMap' :: Monoid m => (a -> m) -> [a] -> m Source foldr :: (a -> b -> b) -> b -> [a] -> b Source foldr' :: (a -> b -> b) -> b -> [a] -> b Source foldl :: (b -> a -> b) -> b -> [a] -> b Source foldl' :: (b -> a -> b) -> b -> [a] -> b Source foldr1 :: (a -> a -> a) -> [a] -> a Source foldl1 :: (a -> a -> a) -> [a] -> a Source elem :: Eq a => a -> [a] -> Bool Source maximum :: Ord a => [a] -> a Source minimum :: Ord a => [a] -> a Source | |
| Foldable (Either a) Source | Since: base-4.7.0.0 |
Defined in Data.Foldable Methodsfold :: Monoid m => Either a m -> m Source foldMap :: Monoid m => (a0 -> m) -> Either a a0 -> m Source foldMap' :: Monoid m => (a0 -> m) -> Either a a0 -> m Source foldr :: (a0 -> b -> b) -> b -> Either a a0 -> b Source foldr' :: (a0 -> b -> b) -> b -> Either a a0 -> b Source foldl :: (b -> a0 -> b) -> b -> Either a a0 -> b Source foldl' :: (b -> a0 -> b) -> b -> Either a a0 -> b Source foldr1 :: (a0 -> a0 -> a0) -> Either a a0 -> a0 Source foldl1 :: (a0 -> a0 -> a0) -> Either a a0 -> a0 Source toList :: Either a a0 -> [a0] Source null :: Either a a0 -> Bool Source length :: Either a a0 -> Int Source elem :: Eq a0 => a0 -> Either a a0 -> Bool Source maximum :: Ord a0 => Either a a0 -> a0 Source minimum :: Ord a0 => Either a a0 -> a0 Source | |
| Foldable (Proxy :: Type -> Type) Source | Since: base-4.7.0.0 |
Defined in Data.Foldable Methodsfold :: Monoid m => Proxy m -> m Source foldMap :: Monoid m => (a -> m) -> Proxy a -> m Source foldMap' :: Monoid m => (a -> m) -> Proxy a -> m Source foldr :: (a -> b -> b) -> b -> Proxy a -> b Source foldr' :: (a -> b -> b) -> b -> Proxy a -> b Source foldl :: (b -> a -> b) -> b -> Proxy a -> b Source foldl' :: (b -> a -> b) -> b -> Proxy a -> b Source foldr1 :: (a -> a -> a) -> Proxy a -> a Source foldl1 :: (a -> a -> a) -> Proxy a -> a Source toList :: Proxy a -> [a] Source null :: Proxy a -> Bool Source length :: Proxy a -> Int Source elem :: Eq a => a -> Proxy a -> Bool Source maximum :: Ord a => Proxy a -> a Source minimum :: Ord a => Proxy a -> a Source | |
| Foldable (Arg a) Source | Since: base-4.9.0.0 |
Defined in Data.Semigroup Methodsfold :: Monoid m => Arg a m -> m Source foldMap :: Monoid m => (a0 -> m) -> Arg a a0 -> m Source foldMap' :: Monoid m => (a0 -> m) -> Arg a a0 -> m Source foldr :: (a0 -> b -> b) -> b -> Arg a a0 -> b Source foldr' :: (a0 -> b -> b) -> b -> Arg a a0 -> b Source foldl :: (b -> a0 -> b) -> b -> Arg a a0 -> b Source foldl' :: (b -> a0 -> b) -> b -> Arg a a0 -> b Source foldr1 :: (a0 -> a0 -> a0) -> Arg a a0 -> a0 Source foldl1 :: (a0 -> a0 -> a0) -> Arg a a0 -> a0 Source toList :: Arg a a0 -> [a0] Source null :: Arg a a0 -> Bool Source length :: Arg a a0 -> Int Source elem :: Eq a0 => a0 -> Arg a a0 -> Bool Source maximum :: Ord a0 => Arg a a0 -> a0 Source minimum :: Ord a0 => Arg a a0 -> a0 Source | |
| Foldable (Array i) Source | Since: base-4.8.0.0 |
Defined in Data.Foldable Methodsfold :: Monoid m => Array i m -> m Source foldMap :: Monoid m => (a -> m) -> Array i a -> m Source foldMap' :: Monoid m => (a -> m) -> Array i a -> m Source foldr :: (a -> b -> b) -> b -> Array i a -> b Source foldr' :: (a -> b -> b) -> b -> Array i a -> b Source foldl :: (b -> a -> b) -> b -> Array i a -> b Source foldl' :: (b -> a -> b) -> b -> Array i a -> b Source foldr1 :: (a -> a -> a) -> Array i a -> a Source foldl1 :: (a -> a -> a) -> Array i a -> a Source toList :: Array i a -> [a] Source null :: Array i a -> Bool Source length :: Array i a -> Int Source elem :: Eq a => a -> Array i a -> Bool Source maximum :: Ord a => Array i a -> a Source minimum :: Ord a => Array i a -> a Source | |
| Foldable (U1 :: Type -> Type) Source | Since: base-4.9.0.0 |
Defined in Data.Foldable Methodsfold :: Monoid m => U1 m -> m Source foldMap :: Monoid m => (a -> m) -> U1 a -> m Source foldMap' :: Monoid m => (a -> m) -> U1 a -> m Source foldr :: (a -> b -> b) -> b -> U1 a -> b Source foldr' :: (a -> b -> b) -> b -> U1 a -> b Source foldl :: (b -> a -> b) -> b -> U1 a -> b Source foldl' :: (b -> a -> b) -> b -> U1 a -> b Source foldr1 :: (a -> a -> a) -> U1 a -> a Source foldl1 :: (a -> a -> a) -> U1 a -> a Source elem :: Eq a => a -> U1 a -> Bool Source maximum :: Ord a => U1 a -> a Source minimum :: Ord a => U1 a -> a Source | |
| Foldable (UAddr :: Type -> Type) Source | Since: base-4.9.0.0 |
Defined in Data.Foldable Methodsfold :: Monoid m => UAddr m -> m Source foldMap :: Monoid m => (a -> m) -> UAddr a -> m Source foldMap' :: Monoid m => (a -> m) -> UAddr a -> m Source foldr :: (a -> b -> b) -> b -> UAddr a -> b Source foldr' :: (a -> b -> b) -> b -> UAddr a -> b Source foldl :: (b -> a -> b) -> b -> UAddr a -> b Source foldl' :: (b -> a -> b) -> b -> UAddr a -> b Source foldr1 :: (a -> a -> a) -> UAddr a -> a Source foldl1 :: (a -> a -> a) -> UAddr a -> a Source toList :: UAddr a -> [a] Source null :: UAddr a -> Bool Source length :: UAddr a -> Int Source elem :: Eq a => a -> UAddr a -> Bool Source maximum :: Ord a => UAddr a -> a Source minimum :: Ord a => UAddr a -> a Source | |
| Foldable (UChar :: Type -> Type) Source | Since: base-4.9.0.0 |
Defined in Data.Foldable Methodsfold :: Monoid m => UChar m -> m Source foldMap :: Monoid m => (a -> m) -> UChar a -> m Source foldMap' :: Monoid m => (a -> m) -> UChar a -> m Source foldr :: (a -> b -> b) -> b -> UChar a -> b Source foldr' :: (a -> b -> b) -> b -> UChar a -> b Source foldl :: (b -> a -> b) -> b -> UChar a -> b Source foldl' :: (b -> a -> b) -> b -> UChar a -> b Source foldr1 :: (a -> a -> a) -> UChar a -> a Source foldl1 :: (a -> a -> a) -> UChar a -> a Source toList :: UChar a -> [a] Source null :: UChar a -> Bool Source length :: UChar a -> Int Source elem :: Eq a => a -> UChar a -> Bool Source maximum :: Ord a => UChar a -> a Source minimum :: Ord a => UChar a -> a Source | |
| Foldable (UDouble :: Type -> Type) Source | Since: base-4.9.0.0 |
Defined in Data.Foldable Methodsfold :: Monoid m => UDouble m -> m Source foldMap :: Monoid m => (a -> m) -> UDouble a -> m Source foldMap' :: Monoid m => (a -> m) -> UDouble a -> m Source foldr :: (a -> b -> b) -> b -> UDouble a -> b Source foldr' :: (a -> b -> b) -> b -> UDouble a -> b Source foldl :: (b -> a -> b) -> b -> UDouble a -> b Source foldl' :: (b -> a -> b) -> b -> UDouble a -> b Source foldr1 :: (a -> a -> a) -> UDouble a -> a Source foldl1 :: (a -> a -> a) -> UDouble a -> a Source toList :: UDouble a -> [a] Source null :: UDouble a -> Bool Source length :: UDouble a -> Int Source elem :: Eq a => a -> UDouble a -> Bool Source maximum :: Ord a => UDouble a -> a Source minimum :: Ord a => UDouble a -> a Source | |
| Foldable (UFloat :: Type -> Type) Source | Since: base-4.9.0.0 |
Defined in Data.Foldable Methodsfold :: Monoid m => UFloat m -> m Source foldMap :: Monoid m => (a -> m) -> UFloat a -> m Source foldMap' :: Monoid m => (a -> m) -> UFloat a -> m Source foldr :: (a -> b -> b) -> b -> UFloat a -> b Source foldr' :: (a -> b -> b) -> b -> UFloat a -> b Source foldl :: (b -> a -> b) -> b -> UFloat a -> b Source foldl' :: (b -> a -> b) -> b -> UFloat a -> b Source foldr1 :: (a -> a -> a) -> UFloat a -> a Source foldl1 :: (a -> a -> a) -> UFloat a -> a Source toList :: UFloat a -> [a] Source null :: UFloat a -> Bool Source length :: UFloat a -> Int Source elem :: Eq a => a -> UFloat a -> Bool Source maximum :: Ord a => UFloat a -> a Source minimum :: Ord a => UFloat a -> a Source | |
| Foldable (UInt :: Type -> Type) Source | Since: base-4.9.0.0 |
Defined in Data.Foldable Methodsfold :: Monoid m => UInt m -> m Source foldMap :: Monoid m => (a -> m) -> UInt a -> m Source foldMap' :: Monoid m => (a -> m) -> UInt a -> m Source foldr :: (a -> b -> b) -> b -> UInt a -> b Source foldr' :: (a -> b -> b) -> b -> UInt a -> b Source foldl :: (b -> a -> b) -> b -> UInt a -> b Source foldl' :: (b -> a -> b) -> b -> UInt a -> b Source foldr1 :: (a -> a -> a) -> UInt a -> a Source foldl1 :: (a -> a -> a) -> UInt a -> a Source toList :: UInt a -> [a] Source length :: UInt a -> Int Source elem :: Eq a => a -> UInt a -> Bool Source maximum :: Ord a => UInt a -> a Source minimum :: Ord a => UInt a -> a Source | |
| Foldable (UWord :: Type -> Type) Source | Since: base-4.9.0.0 |
Defined in Data.Foldable Methodsfold :: Monoid m => UWord m -> m Source foldMap :: Monoid m => (a -> m) -> UWord a -> m Source foldMap' :: Monoid m => (a -> m) -> UWord a -> m Source foldr :: (a -> b -> b) -> b -> UWord a -> b Source foldr' :: (a -> b -> b) -> b -> UWord a -> b Source foldl :: (b -> a -> b) -> b -> UWord a -> b Source foldl' :: (b -> a -> b) -> b -> UWord a -> b Source foldr1 :: (a -> a -> a) -> UWord a -> a Source foldl1 :: (a -> a -> a) -> UWord a -> a Source toList :: UWord a -> [a] Source null :: UWord a -> Bool Source length :: UWord a -> Int Source elem :: Eq a => a -> UWord a -> Bool Source maximum :: Ord a => UWord a -> a Source minimum :: Ord a => UWord a -> a Source | |
| Foldable (V1 :: Type -> Type) Source | Since: base-4.9.0.0 |
Defined in Data.Foldable Methodsfold :: Monoid m => V1 m -> m Source foldMap :: Monoid m => (a -> m) -> V1 a -> m Source foldMap' :: Monoid m => (a -> m) -> V1 a -> m Source foldr :: (a -> b -> b) -> b -> V1 a -> b Source foldr' :: (a -> b -> b) -> b -> V1 a -> b Source foldl :: (b -> a -> b) -> b -> V1 a -> b Source foldl' :: (b -> a -> b) -> b -> V1 a -> b Source foldr1 :: (a -> a -> a) -> V1 a -> a Source foldl1 :: (a -> a -> a) -> V1 a -> a Source elem :: Eq a => a -> V1 a -> Bool Source maximum :: Ord a => V1 a -> a Source minimum :: Ord a => V1 a -> a Source | |
| Foldable ((,) a) Source | Since: base-4.7.0.0 |
Defined in Data.Foldable Methodsfold :: Monoid m => (a, m) -> m Source foldMap :: Monoid m => (a0 -> m) -> (a, a0) -> m Source foldMap' :: Monoid m => (a0 -> m) -> (a, a0) -> m Source foldr :: (a0 -> b -> b) -> b -> (a, a0) -> b Source foldr' :: (a0 -> b -> b) -> b -> (a, a0) -> b Source foldl :: (b -> a0 -> b) -> b -> (a, a0) -> b Source foldl' :: (b -> a0 -> b) -> b -> (a, a0) -> b Source foldr1 :: (a0 -> a0 -> a0) -> (a, a0) -> a0 Source foldl1 :: (a0 -> a0 -> a0) -> (a, a0) -> a0 Source toList :: (a, a0) -> [a0] Source null :: (a, a0) -> Bool Source length :: (a, a0) -> Int Source elem :: Eq a0 => a0 -> (a, a0) -> Bool Source maximum :: Ord a0 => (a, a0) -> a0 Source minimum :: Ord a0 => (a, a0) -> a0 Source | |
| Foldable (Const m :: Type -> Type) Source | Since: base-4.7.0.0 |
Defined in Data.Functor.Const Methodsfold :: Monoid m0 => Const m m0 -> m0 Source foldMap :: Monoid m0 => (a -> m0) -> Const m a -> m0 Source foldMap' :: Monoid m0 => (a -> m0) -> Const m a -> m0 Source foldr :: (a -> b -> b) -> b -> Const m a -> b Source foldr' :: (a -> b -> b) -> b -> Const m a -> b Source foldl :: (b -> a -> b) -> b -> Const m a -> b Source foldl' :: (b -> a -> b) -> b -> Const m a -> b Source foldr1 :: (a -> a -> a) -> Const m a -> a Source foldl1 :: (a -> a -> a) -> Const m a -> a Source toList :: Const m a -> [a] Source null :: Const m a -> Bool Source length :: Const m a -> Int Source elem :: Eq a => a -> Const m a -> Bool Source maximum :: Ord a => Const m a -> a Source minimum :: Ord a => Const m a -> a Source | |
| Foldable f => Foldable (Ap f) Source | Since: base-4.12.0.0 |
Defined in Data.Foldable Methodsfold :: Monoid m => Ap f m -> m Source foldMap :: Monoid m => (a -> m) -> Ap f a -> m Source foldMap' :: Monoid m => (a -> m) -> Ap f a -> m Source foldr :: (a -> b -> b) -> b -> Ap f a -> b Source foldr' :: (a -> b -> b) -> b -> Ap f a -> b Source foldl :: (b -> a -> b) -> b -> Ap f a -> b Source foldl' :: (b -> a -> b) -> b -> Ap f a -> b Source foldr1 :: (a -> a -> a) -> Ap f a -> a Source foldl1 :: (a -> a -> a) -> Ap f a -> a Source toList :: Ap f a -> [a] Source length :: Ap f a -> Int Source elem :: Eq a => a -> Ap f a -> Bool Source maximum :: Ord a => Ap f a -> a Source minimum :: Ord a => Ap f a -> a Source | |
| Foldable f => Foldable (Alt f) Source | Since: base-4.12.0.0 |
Defined in Data.Foldable Methodsfold :: Monoid m => Alt f m -> m Source foldMap :: Monoid m => (a -> m) -> Alt f a -> m Source foldMap' :: Monoid m => (a -> m) -> Alt f a -> m Source foldr :: (a -> b -> b) -> b -> Alt f a -> b Source foldr' :: (a -> b -> b) -> b -> Alt f a -> b Source foldl :: (b -> a -> b) -> b -> Alt f a -> b Source foldl' :: (b -> a -> b) -> b -> Alt f a -> b Source foldr1 :: (a -> a -> a) -> Alt f a -> a Source foldl1 :: (a -> a -> a) -> Alt f a -> a Source toList :: Alt f a -> [a] Source null :: Alt f a -> Bool Source length :: Alt f a -> Int Source elem :: Eq a => a -> Alt f a -> Bool Source maximum :: Ord a => Alt f a -> a Source minimum :: Ord a => Alt f a -> a Source | |
| Foldable f => Foldable (Rec1 f) Source | Since: base-4.9.0.0 |
Defined in Data.Foldable Methodsfold :: Monoid m => Rec1 f m -> m Source foldMap :: Monoid m => (a -> m) -> Rec1 f a -> m Source foldMap' :: Monoid m => (a -> m) -> Rec1 f a -> m Source foldr :: (a -> b -> b) -> b -> Rec1 f a -> b Source foldr' :: (a -> b -> b) -> b -> Rec1 f a -> b Source foldl :: (b -> a -> b) -> b -> Rec1 f a -> b Source foldl' :: (b -> a -> b) -> b -> Rec1 f a -> b Source foldr1 :: (a -> a -> a) -> Rec1 f a -> a Source foldl1 :: (a -> a -> a) -> Rec1 f a -> a Source toList :: Rec1 f a -> [a] Source null :: Rec1 f a -> Bool Source length :: Rec1 f a -> Int Source elem :: Eq a => a -> Rec1 f a -> Bool Source maximum :: Ord a => Rec1 f a -> a Source minimum :: Ord a => Rec1 f a -> a Source | |
| (Foldable f, Foldable g) => Foldable (Product f g) Source | Since: base-4.9.0.0 |
Defined in Data.Functor.Product Methodsfold :: Monoid m => Product f g m -> m Source foldMap :: Monoid m => (a -> m) -> Product f g a -> m Source foldMap' :: Monoid m => (a -> m) -> Product f g a -> m Source foldr :: (a -> b -> b) -> b -> Product f g a -> b Source foldr' :: (a -> b -> b) -> b -> Product f g a -> b Source foldl :: (b -> a -> b) -> b -> Product f g a -> b Source foldl' :: (b -> a -> b) -> b -> Product f g a -> b Source foldr1 :: (a -> a -> a) -> Product f g a -> a Source foldl1 :: (a -> a -> a) -> Product f g a -> a Source toList :: Product f g a -> [a] Source null :: Product f g a -> Bool Source length :: Product f g a -> Int Source elem :: Eq a => a -> Product f g a -> Bool Source maximum :: Ord a => Product f g a -> a Source minimum :: Ord a => Product f g a -> a Source | |
| (Foldable f, Foldable g) => Foldable (Sum f g) Source | Since: base-4.9.0.0 |
Defined in Data.Functor.Sum Methodsfold :: Monoid m => Sum f g m -> m Source foldMap :: Monoid m => (a -> m) -> Sum f g a -> m Source foldMap' :: Monoid m => (a -> m) -> Sum f g a -> m Source foldr :: (a -> b -> b) -> b -> Sum f g a -> b Source foldr' :: (a -> b -> b) -> b -> Sum f g a -> b Source foldl :: (b -> a -> b) -> b -> Sum f g a -> b Source foldl' :: (b -> a -> b) -> b -> Sum f g a -> b Source foldr1 :: (a -> a -> a) -> Sum f g a -> a Source foldl1 :: (a -> a -> a) -> Sum f g a -> a Source toList :: Sum f g a -> [a] Source null :: Sum f g a -> Bool Source length :: Sum f g a -> Int Source elem :: Eq a => a -> Sum f g a -> Bool Source maximum :: Ord a => Sum f g a -> a Source minimum :: Ord a => Sum f g a -> a Source | |
| (Foldable f, Foldable g) => Foldable (f :*: g) Source | Since: base-4.9.0.0 |
Defined in Data.Foldable Methodsfold :: Monoid m => (f :*: g) m -> m Source foldMap :: Monoid m => (a -> m) -> (f :*: g) a -> m Source foldMap' :: Monoid m => (a -> m) -> (f :*: g) a -> m Source foldr :: (a -> b -> b) -> b -> (f :*: g) a -> b Source foldr' :: (a -> b -> b) -> b -> (f :*: g) a -> b Source foldl :: (b -> a -> b) -> b -> (f :*: g) a -> b Source foldl' :: (b -> a -> b) -> b -> (f :*: g) a -> b Source foldr1 :: (a -> a -> a) -> (f :*: g) a -> a Source foldl1 :: (a -> a -> a) -> (f :*: g) a -> a Source toList :: (f :*: g) a -> [a] Source null :: (f :*: g) a -> Bool Source length :: (f :*: g) a -> Int Source elem :: Eq a => a -> (f :*: g) a -> Bool Source maximum :: Ord a => (f :*: g) a -> a Source minimum :: Ord a => (f :*: g) a -> a Source | |
| (Foldable f, Foldable g) => Foldable (f :+: g) Source | Since: base-4.9.0.0 |
Defined in Data.Foldable Methodsfold :: Monoid m => (f :+: g) m -> m Source foldMap :: Monoid m => (a -> m) -> (f :+: g) a -> m Source foldMap' :: Monoid m => (a -> m) -> (f :+: g) a -> m Source foldr :: (a -> b -> b) -> b -> (f :+: g) a -> b Source foldr' :: (a -> b -> b) -> b -> (f :+: g) a -> b Source foldl :: (b -> a -> b) -> b -> (f :+: g) a -> b Source foldl' :: (b -> a -> b) -> b -> (f :+: g) a -> b Source foldr1 :: (a -> a -> a) -> (f :+: g) a -> a Source foldl1 :: (a -> a -> a) -> (f :+: g) a -> a Source toList :: (f :+: g) a -> [a] Source null :: (f :+: g) a -> Bool Source length :: (f :+: g) a -> Int Source elem :: Eq a => a -> (f :+: g) a -> Bool Source maximum :: Ord a => (f :+: g) a -> a Source minimum :: Ord a => (f :+: g) a -> a Source | |
| Foldable (K1 i c :: Type -> Type) Source | Since: base-4.9.0.0 |
Defined in Data.Foldable Methodsfold :: Monoid m => K1 i c m -> m Source foldMap :: Monoid m => (a -> m) -> K1 i c a -> m Source foldMap' :: Monoid m => (a -> m) -> K1 i c a -> m Source foldr :: (a -> b -> b) -> b -> K1 i c a -> b Source foldr' :: (a -> b -> b) -> b -> K1 i c a -> b Source foldl :: (b -> a -> b) -> b -> K1 i c a -> b Source foldl' :: (b -> a -> b) -> b -> K1 i c a -> b Source foldr1 :: (a -> a -> a) -> K1 i c a -> a Source foldl1 :: (a -> a -> a) -> K1 i c a -> a Source toList :: K1 i c a -> [a] Source null :: K1 i c a -> Bool Source length :: K1 i c a -> Int Source elem :: Eq a => a -> K1 i c a -> Bool Source maximum :: Ord a => K1 i c a -> a Source minimum :: Ord a => K1 i c a -> a Source | |
| (Foldable f, Foldable g) => Foldable (Compose f g) Source | Since: base-4.9.0.0 |
Defined in Data.Functor.Compose Methodsfold :: Monoid m => Compose f g m -> m Source foldMap :: Monoid m => (a -> m) -> Compose f g a -> m Source foldMap' :: Monoid m => (a -> m) -> Compose f g a -> m Source foldr :: (a -> b -> b) -> b -> Compose f g a -> b Source foldr' :: (a -> b -> b) -> b -> Compose f g a -> b Source foldl :: (b -> a -> b) -> b -> Compose f g a -> b Source foldl' :: (b -> a -> b) -> b -> Compose f g a -> b Source foldr1 :: (a -> a -> a) -> Compose f g a -> a Source foldl1 :: (a -> a -> a) -> Compose f g a -> a Source toList :: Compose f g a -> [a] Source null :: Compose f g a -> Bool Source length :: Compose f g a -> Int Source elem :: Eq a => a -> Compose f g a -> Bool Source maximum :: Ord a => Compose f g a -> a Source minimum :: Ord a => Compose f g a -> a Source | |
| (Foldable f, Foldable g) => Foldable (f :.: g) Source | Since: base-4.9.0.0 |
Defined in Data.Foldable Methodsfold :: Monoid m => (f :.: g) m -> m Source foldMap :: Monoid m => (a -> m) -> (f :.: g) a -> m Source foldMap' :: Monoid m => (a -> m) -> (f :.: g) a -> m Source foldr :: (a -> b -> b) -> b -> (f :.: g) a -> b Source foldr' :: (a -> b -> b) -> b -> (f :.: g) a -> b Source foldl :: (b -> a -> b) -> b -> (f :.: g) a -> b Source foldl' :: (b -> a -> b) -> b -> (f :.: g) a -> b Source foldr1 :: (a -> a -> a) -> (f :.: g) a -> a Source foldl1 :: (a -> a -> a) -> (f :.: g) a -> a Source toList :: (f :.: g) a -> [a] Source null :: (f :.: g) a -> Bool Source length :: (f :.: g) a -> Int Source elem :: Eq a => a -> (f :.: g) a -> Bool Source maximum :: Ord a => (f :.: g) a -> a Source minimum :: Ord a => (f :.: g) a -> a Source | |
| Foldable f => Foldable (M1 i c f) Source | Since: base-4.9.0.0 |
Defined in Data.Foldable Methodsfold :: Monoid m => M1 i c f m -> m Source foldMap :: Monoid m => (a -> m) -> M1 i c f a -> m Source foldMap' :: Monoid m => (a -> m) -> M1 i c f a -> m Source foldr :: (a -> b -> b) -> b -> M1 i c f a -> b Source foldr' :: (a -> b -> b) -> b -> M1 i c f a -> b Source foldl :: (b -> a -> b) -> b -> M1 i c f a -> b Source foldl' :: (b -> a -> b) -> b -> M1 i c f a -> b Source foldr1 :: (a -> a -> a) -> M1 i c f a -> a Source foldl1 :: (a -> a -> a) -> M1 i c f a -> a Source toList :: M1 i c f a -> [a] Source null :: M1 i c f a -> Bool Source length :: M1 i c f a -> Int Source elem :: Eq a => a -> M1 i c f a -> Bool Source maximum :: Ord a => M1 i c f a -> a Source minimum :: Ord a => M1 i c f a -> a Source | |
class (Functor t, Foldable t) => Traversable t where Source
Functors representing data structures that can be transformed to structures of the same shape by performing an Applicative (or, therefore, Monad) action on each element from left to right.
A more detailed description of what same shape means, the various methods, how traversals are constructed, and example advanced use-cases can be found in the Overview section of Data.Traversable.
For the class laws see the Laws section of Data.Traversable.
traverse :: Applicative f => (a -> f b) -> t a -> f (t b) Source
Map each element of a structure to an action, evaluate these actions from left to right, and collect the results. For a version that ignores the results see traverse_.
Basic usage:
In the first two examples we show each evaluated action mapping to the output structure.
>>> traverse Just [1,2,3,4] Just [1,2,3,4]
>>> traverse id [Right 1, Right 2, Right 3, Right 4] Right [1,2,3,4]
In the next examples, we show that Nothing and Left values short circuit the created structure.
>>> traverse (const Nothing) [1,2,3,4] Nothing
>>> traverse (\x -> if odd x then Just x else Nothing) [1,2,3,4] Nothing
>>> traverse id [Right 1, Right 2, Right 3, Right 4, Left 0] Left 0
sequenceA :: Applicative f => t (f a) -> f (t a) Source
Evaluate each action in the structure from left to right, and collect the results. For a version that ignores the results see sequenceA_.
Basic usage:
For the first two examples we show sequenceA fully evaluating a a structure and collecting the results.
>>> sequenceA [Just 1, Just 2, Just 3] Just [1,2,3]
>>> sequenceA [Right 1, Right 2, Right 3] Right [1,2,3]
The next two example show Nothing and Just will short circuit the resulting structure if present in the input. For more context, check the Traversable instances for Either and Maybe.
>>> sequenceA [Just 1, Just 2, Just 3, Nothing] Nothing
>>> sequenceA [Right 1, Right 2, Right 3, Left 4] Left 4
mapM :: Monad m => (a -> m b) -> t a -> m (t b) Source
Map each element of a structure to a monadic action, evaluate these actions from left to right, and collect the results. For a version that ignores the results see mapM_.
mapM is literally a traverse with a type signature restricted to Monad. Its implementation may be more efficient due to additional power of Monad.
sequence :: Monad m => t (m a) -> m (t a) Source
Evaluate each monadic action in the structure from left to right, and collect the results. For a version that ignores the results see sequence_.
Basic usage:
The first two examples are instances where the input and and output of sequence are isomorphic.
>>> sequence $ Right [1,2,3,4] [Right 1,Right 2,Right 3,Right 4]
>>> sequence $ [Right 1,Right 2,Right 3,Right 4] Right [1,2,3,4]
The following examples demonstrate short circuit behavior for sequence.
>>> sequence $ Left [1,2,3,4] Left [1,2,3,4]
>>> sequence $ [Left 0, Right 1,Right 2,Right 3,Right 4] Left 0
| Traversable ZipList Source | Since: base-4.9.0.0 |
Defined in Data.Traversable | |
| Traversable Complex Source | Since: base-4.9.0.0 |
Defined in Data.Complex | |
| Traversable Identity Source | Since: base-4.9.0.0 |
Defined in Data.Traversable | |
| Traversable First Source | Since: base-4.8.0.0 |
| Traversable Last Source | Since: base-4.8.0.0 |
| Traversable Down Source | Since: base-4.12.0.0 |
| Traversable First Source | Since: base-4.9.0.0 |
| Traversable Last Source | Since: base-4.9.0.0 |
| Traversable Max Source | Since: base-4.9.0.0 |
| Traversable Min Source | Since: base-4.9.0.0 |
| Traversable Dual Source | Since: base-4.8.0.0 |
| Traversable Product Source | Since: base-4.8.0.0 |
Defined in Data.Traversable | |
| Traversable Sum Source | Since: base-4.8.0.0 |
| Traversable Par1 Source | Since: base-4.9.0.0 |
| Traversable NonEmpty Source | Since: base-4.9.0.0 |
Defined in Data.Traversable | |
| Traversable Maybe Source | Since: base-2.1 |
| Traversable Solo Source | Since: base-4.15 |
| Traversable [] Source | Since: base-2.1 |
Defined in Data.Traversable | |
| Traversable (Either a) Source | Since: base-4.7.0.0 |
Defined in Data.Traversable | |
| Traversable (Proxy :: Type -> Type) Source | Since: base-4.7.0.0 |
| Traversable (Arg a) Source | Since: base-4.9.0.0 |
| Ix i => Traversable (Array i) Source | Since: base-2.1 |
Defined in Data.Traversable | |
| Traversable (U1 :: Type -> Type) Source | Since: base-4.9.0.0 |
| Traversable (UAddr :: Type -> Type) Source | Since: base-4.9.0.0 |
| Traversable (UChar :: Type -> Type) Source | Since: base-4.9.0.0 |
| Traversable (UDouble :: Type -> Type) Source | Since: base-4.9.0.0 |
Defined in Data.Traversable | |
| Traversable (UFloat :: Type -> Type) Source | Since: base-4.9.0.0 |
Defined in Data.Traversable | |
| Traversable (UInt :: Type -> Type) Source | Since: base-4.9.0.0 |
| Traversable (UWord :: Type -> Type) Source | Since: base-4.9.0.0 |
| Traversable (V1 :: Type -> Type) Source | Since: base-4.9.0.0 |
| Traversable ((,) a) Source | Since: base-4.7.0.0 |
Defined in Data.Traversable | |
| Traversable (Const m :: Type -> Type) Source | Since: base-4.7.0.0 |
Defined in Data.Traversable | |
| Traversable f => Traversable (Ap f) Source | Since: base-4.12.0.0 |
| Traversable f => Traversable (Alt f) Source | Since: base-4.12.0.0 |
| Traversable f => Traversable (Rec1 f) Source | Since: base-4.9.0.0 |
Defined in Data.Traversable | |
| (Traversable f, Traversable g) => Traversable (Product f g) Source | Since: base-4.9.0.0 |
Defined in Data.Functor.Product Methodstraverse :: Applicative f0 => (a -> f0 b) -> Product f g a -> f0 (Product f g b) Source sequenceA :: Applicative f0 => Product f g (f0 a) -> f0 (Product f g a) Source mapM :: Monad m => (a -> m b) -> Product f g a -> m (Product f g b) Source sequence :: Monad m => Product f g (m a) -> m (Product f g a) Source | |
| (Traversable f, Traversable g) => Traversable (Sum f g) Source | Since: base-4.9.0.0 |
Defined in Data.Functor.Sum | |
| (Traversable f, Traversable g) => Traversable (f :*: g) Source | Since: base-4.9.0.0 |
Defined in Data.Traversable Methodstraverse :: Applicative f0 => (a -> f0 b) -> (f :*: g) a -> f0 ((f :*: g) b) Source sequenceA :: Applicative f0 => (f :*: g) (f0 a) -> f0 ((f :*: g) a) Source mapM :: Monad m => (a -> m b) -> (f :*: g) a -> m ((f :*: g) b) Source sequence :: Monad m => (f :*: g) (m a) -> m ((f :*: g) a) Source | |
| (Traversable f, Traversable g) => Traversable (f :+: g) Source | Since: base-4.9.0.0 |
Defined in Data.Traversable Methodstraverse :: Applicative f0 => (a -> f0 b) -> (f :+: g) a -> f0 ((f :+: g) b) Source sequenceA :: Applicative f0 => (f :+: g) (f0 a) -> f0 ((f :+: g) a) Source mapM :: Monad m => (a -> m b) -> (f :+: g) a -> m ((f :+: g) b) Source sequence :: Monad m => (f :+: g) (m a) -> m ((f :+: g) a) Source | |
| Traversable (K1 i c :: Type -> Type) Source | Since: base-4.9.0.0 |
Defined in Data.Traversable | |
| (Traversable f, Traversable g) => Traversable (Compose f g) Source | Since: base-4.9.0.0 |
Defined in Data.Functor.Compose Methodstraverse :: Applicative f0 => (a -> f0 b) -> Compose f g a -> f0 (Compose f g b) Source sequenceA :: Applicative f0 => Compose f g (f0 a) -> f0 (Compose f g a) Source mapM :: Monad m => (a -> m b) -> Compose f g a -> m (Compose f g b) Source sequence :: Monad m => Compose f g (m a) -> m (Compose f g a) Source | |
| (Traversable f, Traversable g) => Traversable (f :.: g) Source | Since: base-4.9.0.0 |
Defined in Data.Traversable Methodstraverse :: Applicative f0 => (a -> f0 b) -> (f :.: g) a -> f0 ((f :.: g) b) Source sequenceA :: Applicative f0 => (f :.: g) (f0 a) -> f0 ((f :.: g) a) Source mapM :: Monad m => (a -> m b) -> (f :.: g) a -> m ((f :.: g) b) Source sequence :: Monad m => (f :.: g) (m a) -> m ((f :.: g) a) Source | |
| Traversable f => Traversable (M1 i c f) Source | Since: base-4.9.0.0 |
Defined in Data.Traversable | |
Identity function.
id x = x
const x y always evaluates to x, ignoring its second argument.
>>> const 42 "hello" 42
>>> map (const 42) [0..3] [42,42,42,42]
(.) :: (b -> c) -> (a -> b) -> a -> c infixr 9 Source
Function composition.
flip :: (a -> b -> c) -> b -> a -> c Source
flip f takes its (first) two arguments in the reverse order of f.
>>> flip (++) "hello" "world" "worldhello"
($) :: forall r a (b :: TYPE r). (a -> b) -> a -> b infixr 0 Source
Application operator. This operator is redundant, since ordinary application (f x) means the same as (f $ x). However, $ has low, right-associative binding precedence, so it sometimes allows parentheses to be omitted; for example:
f $ g $ h x = f (g (h x))
It is also useful in higher-order situations, such as map ($ 0) xs, or zipWith ($) fs xs.
Note that ($) is representation-polymorphic in its result type, so that foo $ True where foo :: Bool -> Int# is well-typed.
until :: (a -> Bool) -> (a -> a) -> a -> a Source
until p f yields the result of applying f until p holds.
asTypeOf :: a -> a -> a Source
asTypeOf is a type-restricted version of const. It is usually used as an infix operator, and its typing forces its first argument (which is usually overloaded) to have the same type as the second.
error :: forall (r :: RuntimeRep). forall (a :: TYPE r). HasCallStack => [Char] -> a Source
error stops execution and displays an error message.
errorWithoutStackTrace :: forall (r :: RuntimeRep). forall (a :: TYPE r). [Char] -> a Source
A variant of error that does not produce a stack trace.
Since: base-4.9.0.0
undefined :: forall (r :: RuntimeRep). forall (a :: TYPE r). HasCallStack => a Source
A special case of error. It is expected that compilers will recognize this and insert error messages which are more appropriate to the context in which undefined appears.
seq :: forall {r :: RuntimeRep} a (b :: TYPE r). a -> b -> b infixr 0 Source
The value of seq a b is bottom if a is bottom, and otherwise equal to b. In other words, it evaluates the first argument a to weak head normal form (WHNF). seq is usually introduced to improve performance by avoiding unneeded laziness.
A note on evaluation order: the expression seq a b does not guarantee that a will be evaluated before b. The only guarantee given by seq is that the both a and b will be evaluated before seq returns a value. In particular, this means that b may be evaluated before a. If you need to guarantee a specific order of evaluation, you must use the function pseq from the "parallel" package.
($!) :: forall r a (b :: TYPE r). (a -> b) -> a -> b infixr 0 Source
Strict (call-by-value) application operator. It takes a function and an argument, evaluates the argument to weak head normal form (WHNF), then calls the function with that value.
map :: (a -> b) -> [a] -> [b] Source
\(\mathcal{O}(n)\). map f xs is the list obtained by applying f to each element of xs, i.e.,
map f [x1, x2, ..., xn] == [f x1, f x2, ..., f xn] map f [x1, x2, ...] == [f x1, f x2, ...]
>>> map (+1) [1, 2, 3] [2,3,4]
(++) :: [a] -> [a] -> [a] infixr 5 Source
Append two lists, i.e.,
[x1, ..., xm] ++ [y1, ..., yn] == [x1, ..., xm, y1, ..., yn] [x1, ..., xm] ++ [y1, ...] == [x1, ..., xm, y1, ...]
If the first list is not finite, the result is the first list.
WARNING: This function takes linear time in the number of elements of the first list.
filter :: (a -> Bool) -> [a] -> [a] Source
\(\mathcal{O}(n)\). filter, applied to a predicate and a list, returns the list of those elements that satisfy the predicate; i.e.,
filter p xs = [ x | x <- xs, p x]
>>> filter odd [1, 2, 3] [1,3]
head :: HasCallStack => [a] -> a Source
\(\mathcal{O}(1)\). Extract the first element of a list, which must be non-empty.
>>> head [1, 2, 3] 1 >>> head [1..] 1 >>> head [] *** Exception: Prelude.head: empty list
WARNING: This function is partial. You can use case-matching, uncons or listToMaybe instead.
last :: HasCallStack => [a] -> a Source
\(\mathcal{O}(n)\). Extract the last element of a list, which must be finite and non-empty.
>>> last [1, 2, 3] 3 >>> last [1..] * Hangs forever * >>> last [] *** Exception: Prelude.last: empty list
WARNING: This function is partial. You can use reverse with case-matching, uncons or listToMaybe instead.
tail :: HasCallStack => [a] -> [a] Source
\(\mathcal{O}(1)\). Extract the elements after the head of a list, which must be non-empty.
>>> tail [1, 2, 3] [2,3] >>> tail [1] [] >>> tail [] *** Exception: Prelude.tail: empty list
WARNING: This function is partial. You can use case-matching or uncons instead.
init :: HasCallStack => [a] -> [a] Source
\(\mathcal{O}(n)\). Return all the elements of a list except the last one. The list must be non-empty.
>>> init [1, 2, 3] [1,2] >>> init [1] [] >>> init [] *** Exception: Prelude.init: empty list
WARNING: This function is partial. You can use reverse with case-matching or uncons instead.
(!!) :: HasCallStack => [a] -> Int -> a infixl 9 Source
List index (subscript) operator, starting from 0. It is an instance of the more general genericIndex, which takes an index of any integral type.
>>> ['a', 'b', 'c'] !! 0 'a' >>> ['a', 'b', 'c'] !! 2 'c' >>> ['a', 'b', 'c'] !! 3 *** Exception: Prelude.!!: index too large >>> ['a', 'b', 'c'] !! (-1) *** Exception: Prelude.!!: negative index
WARNING: This function is partial. You can use <atMay https://hackage.haskell.org/package/safe-0.3.19/docs/Safe.html#v:atMay> instead.
null :: Foldable t => t a -> Bool Source
Test whether the structure is empty. The default implementation is Left-associative and lazy in both the initial element and the accumulator. Thus optimised for structures where the first element can be accessed in constant time. Structures where this is not the case should have a non-default implementation.
Basic usage:
>>> null [] True
>>> null [1] False
null is expected to terminate even for infinite structures. The default implementation terminates provided the structure is bounded on the left (there is a leftmost element).
>>> null [1..] False
Since: base-4.8.0.0
length :: Foldable t => t a -> Int Source
Returns the size/length of a finite structure as an Int. The default implementation just counts elements starting with the leftmost. Instances for structures that can compute the element count faster than via element-by-element counting, should provide a specialised implementation.
Basic usage:
>>> length [] 0
>>> length ['a', 'b', 'c'] 3 >>> length [1..] * Hangs forever *
Since: base-4.8.0.0
reverse xs returns the elements of xs in reverse order. xs must be finite.
>>> reverse [] [] >>> reverse [42] [42] >>> reverse [2,5,7] [7,5,2] >>> reverse [1..] * Hangs forever *
and :: Foldable t => t Bool -> Bool Source
and returns the conjunction of a container of Bools. For the result to be True, the container must be finite; False, however, results from a False value finitely far from the left end.
Basic usage:
>>> and [] True
>>> and [True] True
>>> and [False] False
>>> and [True, True, False] False
>>> and (False : repeat True) -- Infinite list [False,True,True,True,... False
>>> and (repeat True) * Hangs forever *
or :: Foldable t => t Bool -> Bool Source
or returns the disjunction of a container of Bools. For the result to be False, the container must be finite; True, however, results from a True value finitely far from the left end.
Basic usage:
>>> or [] False
>>> or [True] True
>>> or [False] False
>>> or [True, True, False] True
>>> or (True : repeat False) -- Infinite list [True,False,False,False,... True
>>> or (repeat False) * Hangs forever *
any :: Foldable t => (a -> Bool) -> t a -> Bool Source
Determines whether any element of the structure satisfies the predicate.
Basic usage:
>>> any (> 3) [] False
>>> any (> 3) [1,2] False
>>> any (> 3) [1,2,3,4,5] True
>>> any (> 3) [1..] True
>>> any (> 3) [0, -1..] * Hangs forever *
all :: Foldable t => (a -> Bool) -> t a -> Bool Source
Determines whether all elements of the structure satisfy the predicate.
Basic usage:
>>> all (> 3) [] True
>>> all (> 3) [1,2] False
>>> all (> 3) [1,2,3,4,5] False
>>> all (> 3) [1..] False
>>> all (> 3) [4..] * Hangs forever *
concat :: Foldable t => t [a] -> [a] Source
The concatenation of all the elements of a container of lists.
Basic usage:
>>> concat (Just [1, 2, 3]) [1,2,3]
>>> concat (Left 42) []
>>> concat [[1, 2, 3], [4, 5], [6], []] [1,2,3,4,5,6]
concatMap :: Foldable t => (a -> [b]) -> t a -> [b] Source
Map a function over all the elements of a container and concatenate the resulting lists.
Basic usage:
>>> concatMap (take 3) [[1..], [10..], [100..], [1000..]] [1,2,3,10,11,12,100,101,102,1000,1001,1002]
>>> concatMap (take 3) (Just [1..]) [1,2,3]
scanl :: (b -> a -> b) -> b -> [a] -> [b] Source
\(\mathcal{O}(n)\). scanl is similar to foldl, but returns a list of successive reduced values from the left:
scanl f z [x1, x2, ...] == [z, z `f` x1, (z `f` x1) `f` x2, ...]
Note that
last (scanl f z xs) == foldl f z xs
>>> scanl (+) 0 [1..4] [0,1,3,6,10] >>> scanl (+) 42 [] [42] >>> scanl (-) 100 [1..4] [100,99,97,94,90] >>> scanl (\reversedString nextChar -> nextChar : reversedString) "foo" ['a', 'b', 'c', 'd'] ["foo","afoo","bafoo","cbafoo","dcbafoo"] >>> scanl (+) 0 [1..] * Hangs forever *
scanl1 :: (a -> a -> a) -> [a] -> [a] Source
\(\mathcal{O}(n)\). scanl1 is a variant of scanl that has no starting value argument:
scanl1 f [x1, x2, ...] == [x1, x1 `f` x2, ...]
>>> scanl1 (+) [1..4] [1,3,6,10] >>> scanl1 (+) [] [] >>> scanl1 (-) [1..4] [1,-1,-4,-8] >>> scanl1 (&&) [True, False, True, True] [True,False,False,False] >>> scanl1 (||) [False, False, True, True] [False,False,True,True] >>> scanl1 (+) [1..] * Hangs forever *
scanr :: (a -> b -> b) -> b -> [a] -> [b] Source
\(\mathcal{O}(n)\). scanr is the right-to-left dual of scanl. Note that the order of parameters on the accumulating function are reversed compared to scanl. Also note that
head (scanr f z xs) == foldr f z xs.
>>> scanr (+) 0 [1..4] [10,9,7,4,0] >>> scanr (+) 42 [] [42] >>> scanr (-) 100 [1..4] [98,-97,99,-96,100] >>> scanr (\nextChar reversedString -> nextChar : reversedString) "foo" ['a', 'b', 'c', 'd'] ["abcdfoo","bcdfoo","cdfoo","dfoo","foo"] >>> force $ scanr (+) 0 [1..] *** Exception: stack overflow
scanr1 :: (a -> a -> a) -> [a] -> [a] Source
\(\mathcal{O}(n)\). scanr1 is a variant of scanr that has no starting value argument.
>>> scanr1 (+) [1..4] [10,9,7,4] >>> scanr1 (+) [] [] >>> scanr1 (-) [1..4] [-2,3,-1,4] >>> scanr1 (&&) [True, False, True, True] [False,False,True,True] >>> scanr1 (||) [True, True, False, False] [True,True,False,False] >>> force $ scanr1 (+) [1..] *** Exception: stack overflow
iterate :: (a -> a) -> a -> [a] Source
iterate f x returns an infinite list of repeated applications of f to x:
iterate f x == [x, f x, f (f x), ...]
Note that iterate is lazy, potentially leading to thunk build-up if the consumer doesn't force each iterate. See iterate' for a strict variant of this function.
>>> take 10 $ iterate not True [True,False,True,False... >>> take 10 $ iterate (+3) 42 [42,45,48,51,54,57,60,63...
repeat x is an infinite list, with x the value of every element.
>>> take 20 $ repeat 17 [17,17,17,17,17,17,17,17,17...
replicate :: Int -> a -> [a] Source
replicate n x is a list of length n with x the value of every element. It is an instance of the more general genericReplicate, in which n may be of any integral type.
>>> replicate 0 True [] >>> replicate (-1) True [] >>> replicate 4 True [True,True,True,True]
cycle :: HasCallStack => [a] -> [a] Source
cycle ties a finite list into a circular one, or equivalently, the infinite repetition of the original list. It is the identity on infinite lists.
>>> cycle [] *** Exception: Prelude.cycle: empty list >>> take 20 $ cycle [42] [42,42,42,42,42,42,42,42,42,42... >>> take 20 $ cycle [2, 5, 7] [2,5,7,2,5,7,2,5,7,2,5,7...
take :: Int -> [a] -> [a] Source
take n, applied to a list xs, returns the prefix of xs of length n, or xs itself if n >= length xs.
>>> take 5 "Hello World!" "Hello" >>> take 3 [1,2,3,4,5] [1,2,3] >>> take 3 [1,2] [1,2] >>> take 3 [] [] >>> take (-1) [1,2] [] >>> take 0 [1,2] []
It is an instance of the more general genericTake, in which n may be of any integral type.
drop :: Int -> [a] -> [a] Source
drop n xs returns the suffix of xs after the first n elements, or [] if n >= length xs.
>>> drop 6 "Hello World!" "World!" >>> drop 3 [1,2,3,4,5] [4,5] >>> drop 3 [1,2] [] >>> drop 3 [] [] >>> drop (-1) [1,2] [1,2] >>> drop 0 [1,2] [1,2]
It is an instance of the more general genericDrop, in which n may be of any integral type.
takeWhile :: (a -> Bool) -> [a] -> [a] Source
takeWhile, applied to a predicate p and a list xs, returns the longest prefix (possibly empty) of xs of elements that satisfy p.
>>> takeWhile (< 3) [1,2,3,4,1,2,3,4] [1,2] >>> takeWhile (< 9) [1,2,3] [1,2,3] >>> takeWhile (< 0) [1,2,3] []
dropWhile :: (a -> Bool) -> [a] -> [a] Source
dropWhile p xs returns the suffix remaining after takeWhile p xs.
>>> dropWhile (< 3) [1,2,3,4,5,1,2,3] [3,4,5,1,2,3] >>> dropWhile (< 9) [1,2,3] [] >>> dropWhile (< 0) [1,2,3] [1,2,3]
span :: (a -> Bool) -> [a] -> ([a], [a]) Source
span, applied to a predicate p and a list xs, returns a tuple where first element is longest prefix (possibly empty) of xs of elements that satisfy p and second element is the remainder of the list:
>>> span (< 3) [1,2,3,4,1,2,3,4] ([1,2],[3,4,1,2,3,4]) >>> span (< 9) [1,2,3] ([1,2,3],[]) >>> span (< 0) [1,2,3] ([],[1,2,3])
span p xs is equivalent to (takeWhile p xs, dropWhile p xs)
break :: (a -> Bool) -> [a] -> ([a], [a]) Source
break, applied to a predicate p and a list xs, returns a tuple where first element is longest prefix (possibly empty) of xs of elements that do not satisfy p and second element is the remainder of the list:
>>> break (> 3) [1,2,3,4,1,2,3,4] ([1,2,3],[4,1,2,3,4]) >>> break (< 9) [1,2,3] ([],[1,2,3]) >>> break (> 9) [1,2,3] ([1,2,3],[])
break p is equivalent to span (not . p).
splitAt :: Int -> [a] -> ([a], [a]) Source
splitAt n xs returns a tuple where first element is xs prefix of length n and second element is the remainder of the list:
>>> splitAt 6 "Hello World!"
("Hello ","World!")
>>> splitAt 3 [1,2,3,4,5]
([1,2,3],[4,5])
>>> splitAt 1 [1,2,3]
([1],[2,3])
>>> splitAt 3 [1,2,3]
([1,2,3],[])
>>> splitAt 4 [1,2,3]
([1,2,3],[])
>>> splitAt 0 [1,2,3]
([],[1,2,3])
>>> splitAt (-1) [1,2,3]
([],[1,2,3])
It is equivalent to (take n xs, drop n xs) when n is not _|_ (splitAt _|_ xs = _|_). splitAt is an instance of the more general genericSplitAt, in which n may be of any integral type.
notElem :: (Foldable t, Eq a) => a -> t a -> Bool infix 4 Source
notElem is the negation of elem.
Basic usage:
>>> 3 `notElem` [] True
>>> 3 `notElem` [1,2] True
>>> 3 `notElem` [1,2,3,4,5] False
For infinite structures, notElem terminates if the value exists at a finite distance from the left side of the structure:
>>> 3 `notElem` [1..] False
>>> 3 `notElem` ([4..] ++ [3]) * Hangs forever *
lookup :: Eq a => a -> [(a, b)] -> Maybe b Source
\(\mathcal{O}(n)\). lookup key assocs looks up a key in an association list.
>>> lookup 2 [] Nothing >>> lookup 2 [(1, "first")] Nothing >>> lookup 2 [(1, "first"), (2, "second"), (3, "third")] Just "second"
zip :: [a] -> [b] -> [(a, b)] Source
\(\mathcal{O}(\min(m,n))\). zip takes two lists and returns a list of corresponding pairs.
>>> zip [1, 2] ['a', 'b'] [(1,'a'),(2,'b')]
If one input list is shorter than the other, excess elements of the longer list are discarded, even if one of the lists is infinite:
>>> zip [1] ['a', 'b'] [(1,'a')] >>> zip [1, 2] ['a'] [(1,'a')] >>> zip [] [1..] [] >>> zip [1..] [] []
zip is right-lazy:
>>> zip [] undefined [] >>> zip undefined [] *** Exception: Prelude.undefined ...
zip is capable of list fusion, but it is restricted to its first list argument and its resulting list.
zip3 :: [a] -> [b] -> [c] -> [(a, b, c)] Source
zip3 takes three lists and returns a list of triples, analogous to zip. It is capable of list fusion, but it is restricted to its first list argument and its resulting list.
zipWith :: (a -> b -> c) -> [a] -> [b] -> [c] Source
\(\mathcal{O}(\min(m,n))\). zipWith generalises zip by zipping with the function given as the first argument, instead of a tupling function.
zipWith (,) xs ys == zip xs ys zipWith f [x1,x2,x3..] [y1,y2,y3..] == [f x1 y1, f x2 y2, f x3 y3..]
For example, zipWith (+) is applied to two lists to produce the list of corresponding sums:
>>> zipWith (+) [1, 2, 3] [4, 5, 6] [5,7,9]
zipWith is right-lazy:
>>> let f = undefined >>> zipWith f [] undefined []
zipWith is capable of list fusion, but it is restricted to its first list argument and its resulting list.
zipWith3 :: (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d] Source
The zipWith3 function takes a function which combines three elements, as well as three lists and returns a list of the function applied to corresponding elements, analogous to zipWith. It is capable of list fusion, but it is restricted to its first list argument and its resulting list.
zipWith3 (,,) xs ys zs == zip3 xs ys zs zipWith3 f [x1,x2,x3..] [y1,y2,y3..] [z1,z2,z3..] == [f x1 y1 z1, f x2 y2 z2, f x3 y3 z3..]
unzip :: [(a, b)] -> ([a], [b]) Source
unzip transforms a list of pairs into a list of first components and a list of second components.
>>> unzip [] ([],[]) >>> unzip [(1, 'a'), (2, 'b')] ([1,2],"ab")
unzip3 :: [(a, b, c)] -> ([a], [b], [c]) Source
The unzip3 function takes a list of triples and returns three lists, analogous to unzip.
>>> unzip3 [] ([],[],[]) >>> unzip3 [(1, 'a', True), (2, 'b', False)] ([1,2],"ab",[True,False])
lines :: String -> [String] Source
Splits the argument into a list of lines stripped of their terminating n characters. The n terminator is optional in a final non-empty line of the argument string.
For example:
>>> lines "" -- empty input contains no lines []
>>> lines "\n" -- single empty line [""]
>>> lines "one" -- single unterminated line ["one"]
>>> lines "one\n" -- single non-empty line ["one"]
>>> lines "one\n\n" -- second line is empty ["one",""]
>>> lines "one\ntwo" -- second line is unterminated ["one","two"]
>>> lines "one\ntwo\n" -- two non-empty lines ["one","two"]
When the argument string is empty, or ends in a n character, it can be recovered by passing the result of lines to the unlines function. Otherwise, unlines appends the missing terminating n. This makes unlines . lines idempotent:
(unlines . lines) . (unlines . lines) = (unlines . lines)
words :: String -> [String] Source
words breaks a string up into a list of words, which were delimited by white space.
>>> words "Lorem ipsum\ndolor" ["Lorem","ipsum","dolor"]
unlines :: [String] -> String Source
Appends a n character to each input string, then concatenates the results. Equivalent to foldMap (s -> s ++ "n").
>>> unlines ["Hello", "World", "!"] "Hello\nWorld\n!\n"
unlines . lines /= id when the input is not n-terminated:
>>> unlines . lines $ "foo\nbar" "foo\nbar\n"
unwords :: [String] -> String Source
unwords is an inverse operation to words. It joins words with separating spaces.
>>> unwords ["Lorem", "ipsum", "dolor"] "Lorem ipsum dolor"
String
type ShowS = String -> String Source
The shows functions return a function that prepends the output String to an existing String. This allows constant-time concatenation of results using function composition.
Conversion of values to readable Strings.
Derived instances of Show have the following properties, which are compatible with derived instances of Read:
show is a syntactically correct Haskell expression containing only constants, given the fixity declarations in force at the point where the type is declared. It contains only the constructor names defined in the data type, parentheses, and spaces. When labelled constructor fields are used, braces, commas, field names, and equal signs are also used.showsPrec will produce infix applications of the constructor.x is less than d (associativity is ignored). Thus, if d is 0 then the result is never surrounded in parentheses; if d is 11 it is always surrounded in parentheses, unless it is an atomic expression.show will produce the record-syntax form, with the fields given in the same order as the original declaration.For example, given the declarations
infixr 5 :^: data Tree a = Leaf a | Tree a :^: Tree a
the derived instance of Show is equivalent to
instance (Show a) => Show (Tree a) where
showsPrec d (Leaf m) = showParen (d > app_prec) $
showString "Leaf " . showsPrec (app_prec+1) m
where app_prec = 10
showsPrec d (u :^: v) = showParen (d > up_prec) $
showsPrec (up_prec+1) u .
showString " :^: " .
showsPrec (up_prec+1) v
where up_prec = 5
Note that right-associativity of :^: is ignored. For example,
show (Leaf 1 :^: Leaf 2 :^: Leaf 3) produces the string "Leaf 1 :^: (Leaf 2 :^: Leaf 3)".| :: Int | the operator precedence of the enclosing context (a number from |
| -> a | the value to be converted to a |
| -> ShowS |
Convert a value to a readable String.
showsPrec should satisfy the law
showsPrec d x r ++ s == showsPrec d x (r ++ s)
Derived instances of Read and Show satisfy the following:
That is, readsPrec parses the string produced by showsPrec, and delivers the value that showsPrec started with.
A specialised variant of showsPrec, using precedence context zero, and returning an ordinary String.
showList :: [a] -> ShowS Source
The method showList is provided to allow the programmer to give a specialised way of showing lists of values. For example, this is used by the predefined Show instance of the Char type, where values of type String should be shown in double quotes, rather than between square brackets.
shows :: Show a => a -> ShowS Source
equivalent to showsPrec with a precedence of 0.
showChar :: Char -> ShowS Source
utility function converting a Char to a show function that simply prepends the character unchanged.
showString :: String -> ShowS Source
utility function converting a String to a show function that simply prepends the string unchanged.
showParen :: Bool -> ShowS -> ShowS Source
utility function that surrounds the inner show function with parentheses when the Bool parameter is True.
String
type ReadS a = String -> [(a, String)] Source
A parser for a type a, represented as a function that takes a String and returns a list of possible parses as (a,String) pairs.
Note that this kind of backtracking parser is very inefficient; reading a large structure may be quite slow (cf ReadP).
Parsing of Strings, producing values.
Derived instances of Read make the following assumptions, which derived instances of Show obey:
Read instance will parse only infix applications of the constructor (not the prefix form).Read will parse only the record-syntax form, and furthermore, the fields must be given in the same order as the original declaration.Read instance allows arbitrary Haskell whitespace between tokens of the input string. Extra parentheses are also allowed.For example, given the declarations
infixr 5 :^: data Tree a = Leaf a | Tree a :^: Tree a
the derived instance of Read in Haskell 2010 is equivalent to
instance (Read a) => Read (Tree a) where
readsPrec d r = readParen (d > app_prec)
(\r -> [(Leaf m,t) |
("Leaf",s) <- lex r,
(m,t) <- readsPrec (app_prec+1) s]) r
++ readParen (d > up_prec)
(\r -> [(u:^:v,w) |
(u,s) <- readsPrec (up_prec+1) r,
(":^:",t) <- lex s,
(v,w) <- readsPrec (up_prec+1) t]) r
where app_prec = 10
up_prec = 5
Note that right-associativity of :^: is unused.
The derived instance in GHC is equivalent to
instance (Read a) => Read (Tree a) where
readPrec = parens $ (prec app_prec $ do
Ident "Leaf" <- lexP
m <- step readPrec
return (Leaf m))
+++ (prec up_prec $ do
u <- step readPrec
Symbol ":^:" <- lexP
v <- step readPrec
return (u :^: v))
where app_prec = 10
up_prec = 5
readListPrec = readListPrecDefault
Why do both readsPrec and readPrec exist, and why does GHC opt to implement readPrec in derived Read instances instead of readsPrec? The reason is that readsPrec is based on the ReadS type, and although ReadS is mentioned in the Haskell 2010 Report, it is not a very efficient parser data structure.
readPrec, on the other hand, is based on a much more efficient ReadPrec datatype (a.k.a "new-style parsers"), but its definition relies on the use of the RankNTypes language extension. Therefore, readPrec (and its cousin, readListPrec) are marked as GHC-only. Nevertheless, it is recommended to use readPrec instead of readsPrec whenever possible for the efficiency improvements it brings.
As mentioned above, derived Read instances in GHC will implement readPrec instead of readsPrec. The default implementations of readsPrec (and its cousin, readList) will simply use readPrec under the hood. If you are writing a Read instance by hand, it is recommended to write it like so:
instance Read T where readPrec = ... readListPrec = readListPrecDefault
| :: Int | the operator precedence of the enclosing context (a number from |
| -> ReadS a |
attempts to parse a value from the front of the string, returning a list of (parsed value, remaining string) pairs. If there is no successful parse, the returned list is empty.
Derived instances of Read and Show satisfy the following:
That is, readsPrec parses the string produced by showsPrec, and delivers the value that showsPrec started with.
The method readList is provided to allow the programmer to give a specialised way of parsing lists of values. For example, this is used by the predefined Read instance of the Char type, where values of type String should be are expected to use double quotes, rather than square brackets.
| Read All Source | Since: base-2.1 |
| Read Any Source | Since: base-2.1 |
| Read Version Source | Since: base-2.1 |
| Read Void Source |
Reading a Since: base-4.8.0.0 |
| Read CBool Source | |
| Read CChar Source | |
| Read CClock Source | |
| Read CDouble Source | |
| Read CFloat Source | |
| Read CInt Source | |
| Read CIntMax Source | |
| Read CIntPtr Source | |
| Read CLLong Source | |
| Read CLong Source | |
| Read CPtrdiff Source | |
| Read CSChar Source | |
| Read CSUSeconds Source | |
Defined in Foreign.C.Types MethodsreadsPrec :: Int -> ReadS CSUSeconds Source readList :: ReadS [CSUSeconds] Source | |
| Read CShort Source | |
| Read CSigAtomic Source | |
Defined in Foreign.C.Types MethodsreadsPrec :: Int -> ReadS CSigAtomic Source readList :: ReadS [CSigAtomic] Source | |
| Read CSize Source | |
| Read CTime Source | |
| Read CUChar Source | |
| Read CUInt Source | |
| Read CUIntMax Source | |
| Read CUIntPtr Source | |
| Read CULLong Source | |
| Read CULong Source | |
| Read CUSeconds Source | |
| Read CUShort Source | |
| Read CWchar Source | |
| Read IntPtr Source | |
| Read WordPtr Source | |
| Read ByteOrder Source | Since: base-4.11.0.0 |
| Read Associativity Source | Since: base-4.6.0.0 |
Defined in GHC.Generics MethodsreadsPrec :: Int -> ReadS Associativity Source readList :: ReadS [Associativity] Source | |
| Read DecidedStrictness Source | Since: base-4.9.0.0 |
Defined in GHC.Generics MethodsreadsPrec :: Int -> ReadS DecidedStrictness Source readList :: ReadS [DecidedStrictness] Source | |
| Read Fixity Source | Since: base-4.6.0.0 |
| Read SourceStrictness Source | Since: base-4.9.0.0 |
Defined in GHC.Generics MethodsreadsPrec :: Int -> ReadS SourceStrictness Source readList :: ReadS [SourceStrictness] Source | |
| Read SourceUnpackedness Source | Since: base-4.9.0.0 |
Defined in GHC.Generics MethodsreadsPrec :: Int -> ReadS SourceUnpackedness Source readList :: ReadS [SourceUnpackedness] Source | |
| Read SeekMode Source | Since: base-4.2.0.0 |
| Read ExitCode Source | |
| Read BufferMode Source | Since: base-4.2.0.0 |
Defined in GHC.IO.Handle.Types MethodsreadsPrec :: Int -> ReadS BufferMode Source readList :: ReadS [BufferMode] Source | |
| Read Newline Source | Since: base-4.3.0.0 |
| Read NewlineMode Source | Since: base-4.3.0.0 |
Defined in GHC.IO.Handle.Types MethodsreadsPrec :: Int -> ReadS NewlineMode Source readList :: ReadS [NewlineMode] Source | |
| Read IOMode Source | Since: base-4.2.0.0 |
| Read Int16 Source | Since: base-2.1 |
| Read Int32 Source | Since: base-2.1 |
| Read Int64 Source | Since: base-2.1 |
| Read Int8 Source | Since: base-2.1 |
| Read GCDetails Source | Since: base-4.10.0.0 |
| Read RTSStats Source | Since: base-4.10.0.0 |
| Read SomeChar Source | |
| Read SomeSymbol Source | Since: base-4.7.0.0 |
Defined in GHC.TypeLits MethodsreadsPrec :: Int -> ReadS SomeSymbol Source readList :: ReadS [SomeSymbol] Source | |
| Read SomeNat Source | Since: base-4.7.0.0 |
| Read GeneralCategory Source | Since: base-2.1 |
Defined in GHC.Read MethodsreadsPrec :: Int -> ReadS GeneralCategory Source readList :: ReadS [GeneralCategory] Source | |
| Read Word16 Source | Since: base-2.1 |
| Read Word32 Source | Since: base-2.1 |
| Read Word64 Source | Since: base-2.1 |
| Read Word8 Source | Since: base-2.1 |
| Read CBlkCnt Source | |
| Read CBlkSize Source | |
| Read CCc Source | |
| Read CClockId Source | |
| Read CDev Source | |
| Read CFsBlkCnt Source | |
| Read CFsFilCnt Source | |
| Read CGid Source | |
| Read CId Source | |
| Read CIno Source | |
| Read CKey Source | |
| Read CMode Source | |
| Read CNfds Source | |
| Read CNlink Source | |
| Read COff Source | |
| Read CPid Source | |
| Read CRLim Source | |
| Read CSocklen Source | |
| Read CSpeed Source | |
| Read CSsize Source | |
| Read CTcflag Source | |
| Read CUid Source | |
| Read Fd Source | |
| Read Lexeme Source | Since: base-2.1 |
| Read Ordering Source | Since: base-2.1 |
| Read Integer Source | Since: base-2.1 |
| Read Natural Source | Since: base-4.8.0.0 |
| Read () Source | Since: base-2.1 |
| Read Bool Source | Since: base-2.1 |
| Read Char Source | Since: base-2.1 |
| Read Double Source | Since: base-2.1 |
| Read Float Source | Since: base-2.1 |
| Read Int Source | Since: base-2.1 |
| Read Word Source | Since: base-4.5.0.0 |
| Read a => Read (ZipList a) Source | Since: base-4.7.0.0 |
| Read a => Read (And a) Source | Since: base-4.16 |
| Read a => Read (Iff a) Source | Since: base-4.16 |
| Read a => Read (Ior a) Source | Since: base-4.16 |
| Read a => Read (Xor a) Source | Since: base-4.16 |
| Read a => Read (Complex a) Source | Since: base-2.1 |
| Read a => Read (Identity a) Source |
This instance would be equivalent to the derived instances of the Since: base-4.8.0.0 |
| Read a => Read (First a) Source | Since: base-2.1 |
| Read a => Read (Last a) Source | Since: base-2.1 |
| Read a => Read (Down a) Source |
This instance would be equivalent to the derived instances of the Since: base-4.7.0.0 |
| Read a => Read (First a) Source | Since: base-4.9.0.0 |
| Read a => Read (Last a) Source | Since: base-4.9.0.0 |
| Read a => Read (Max a) Source | Since: base-4.9.0.0 |
| Read a => Read (Min a) Source | Since: base-4.9.0.0 |
| Read m => Read (WrappedMonoid m) Source | Since: base-4.9.0.0 |
Defined in Data.Semigroup MethodsreadsPrec :: Int -> ReadS (WrappedMonoid m) Source readList :: ReadS [WrappedMonoid m] Source readPrec :: ReadPrec (WrappedMonoid m) Source readListPrec :: ReadPrec [WrappedMonoid m] Source | |
| Read a => Read (Dual a) Source | Since: base-2.1 |
| Read a => Read (Product a) Source | Since: base-2.1 |
| Read a => Read (Sum a) Source | Since: base-2.1 |
| Read p => Read (Par1 p) Source | Since: base-4.7.0.0 |
| (Integral a, Read a) => Read (Ratio a) Source | Since: base-2.1 |
| Read a => Read (NonEmpty a) Source | Since: base-4.11.0.0 |
| Read a => Read (Maybe a) Source | Since: base-2.1 |
| Read a => Read (a) Source | Since: base-4.15 |
| Read a => Read [a] Source | Since: base-2.1 |
| (Read a, Read b) => Read (Either a b) Source | Since: base-3.0 |
| HasResolution a => Read (Fixed a) Source | Since: base-4.3.0.0 |
| Read (Proxy t) Source | Since: base-4.7.0.0 |
| (Read a, Read b) => Read (Arg a b) Source | Since: base-4.9.0.0 |
| (Ix a, Read a, Read b) => Read (Array a b) Source | Since: base-2.1 |
| Read (U1 p) Source | Since: base-4.9.0.0 |
| Read (V1 p) Source | Since: base-4.9.0.0 |
| (Read a, Read b) => Read (a, b) Source | Since: base-2.1 |
| Read a => Read (Const a b) Source |
This instance would be equivalent to the derived instances of the Since: base-4.8.0.0 |
| Read (f a) => Read (Ap f a) Source | Since: base-4.12.0.0 |
| Read (f a) => Read (Alt f a) Source | Since: base-4.8.0.0 |
| Coercible a b => Read (Coercion a b) Source | Since: base-4.7.0.0 |
| a ~ b => Read (a :~: b) Source | Since: base-4.7.0.0 |
| Read (f p) => Read (Rec1 f p) Source | Since: base-4.7.0.0 |
| (Read a, Read b, Read c) => Read (a, b, c) Source | Since: base-2.1 |
| (Read1 f, Read1 g, Read a) => Read (Product f g a) Source | Since: base-4.9.0.0 |
| (Read1 f, Read1 g, Read a) => Read (Sum f g a) Source | Since: base-4.9.0.0 |
| a ~~ b => Read (a :~~: b) Source | Since: base-4.10.0.0 |
| (Read (f p), Read (g p)) => Read ((f :*: g) p) Source | Since: base-4.7.0.0 |
| (Read (f p), Read (g p)) => Read ((f :+: g) p) Source | Since: base-4.7.0.0 |
| Read c => Read (K1 i c p) Source | Since: base-4.7.0.0 |
| (Read a, Read b, Read c, Read d) => Read (a, b, c, d) Source | Since: base-2.1 |
| (Read1 f, Read1 g, Read a) => Read (Compose f g a) Source | Since: base-4.9.0.0 |
| Read (f (g p)) => Read ((f :.: g) p) Source | Since: base-4.7.0.0 |
| Read (f p) => Read (M1 i c f p) Source | Since: base-4.7.0.0 |
| (Read a, Read b, Read c, Read d, Read e) => Read (a, b, c, d, e) Source | Since: base-2.1 |
| (Read a, Read b, Read c, Read d, Read e, Read f) => Read (a, b, c, d, e, f) Source | Since: base-2.1 |
| (Read a, Read b, Read c, Read d, Read e, Read f, Read g) => Read (a, b, c, d, e, f, g) Source | Since: base-2.1 |
| (Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h) => Read (a, b, c, d, e, f, g, h) Source | Since: base-2.1 |
| (Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i) => Read (a, b, c, d, e, f, g, h, i) Source | Since: base-2.1 |
| (Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j) => Read (a, b, c, d, e, f, g, h, i, j) Source | Since: base-2.1 |
| (Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j, Read k) => Read (a, b, c, d, e, f, g, h, i, j, k) Source | Since: base-2.1 |
| (Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j, Read k, Read l) => Read (a, b, c, d, e, f, g, h, i, j, k, l) Source | Since: base-2.1 |
| (Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j, Read k, Read l, Read m) => Read (a, b, c, d, e, f, g, h, i, j, k, l, m) Source | Since: base-2.1 |
Defined in GHC.Read | |
| (Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j, Read k, Read l, Read m, Read n) => Read (a, b, c, d, e, f, g, h, i, j, k, l, m, n) Source | Since: base-2.1 |
Defined in GHC.Read MethodsreadsPrec :: Int -> ReadS (a, b, c, d, e, f, g, h, i, j, k, l, m, n) Source readList :: ReadS [(a, b, c, d, e, f, g, h, i, j, k, l, m, n)] Source readPrec :: ReadPrec (a, b, c, d, e, f, g, h, i, j, k, l, m, n) Source readListPrec :: ReadPrec [(a, b, c, d, e, f, g, h, i, j, k, l, m, n)] Source | |
| (Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j, Read k, Read l, Read m, Read n, Read o) => Read (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) Source | Since: base-2.1 |
Defined in GHC.Read MethodsreadsPrec :: Int -> ReadS (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) Source readList :: ReadS [(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)] Source readPrec :: ReadPrec (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) Source readListPrec :: ReadPrec [(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)] Source | |
reads :: Read a => ReadS a Source
equivalent to readsPrec with a precedence of 0.
readParen :: Bool -> ReadS a -> ReadS a Source
readParen True p parses what p parses, but surrounded with parentheses.
readParen False p parses what p parses, but optionally surrounded with parentheses.
read :: Read a => String -> a Source
The read function reads input from a string, which must be completely consumed by the input process. read fails with an error if the parse is unsuccessful, and it is therefore discouraged from being used in real applications. Use readMaybe or readEither for safe alternatives.
>>> read "123" :: Int 123
>>> read "hello" :: Int *** Exception: Prelude.read: no parse
The lex function reads a single lexeme from the input, discarding initial white space, and returning the characters that constitute the lexeme. If the input string contains only white space, lex returns a single successful `lexeme' consisting of the empty string. (Thus lex "" = [("","")].) If there is no legal lexeme at the beginning of the input string, lex fails (i.e. returns []).
This lexer is not completely faithful to the Haskell lexical syntax in the following respects:
A value of type IO a is a computation which, when performed, does some I/O before returning a value of type a.
There is really only one way to "perform" an I/O action: bind it to Main.main in your program. When your program is run, the I/O will be performed. It isn't possible to perform I/O from an arbitrary function, unless that function is itself in the IO monad and called at some point, directly or indirectly, from Main.main.
IO is a monad, so IO actions can be combined using either the do-notation or the >> and >>= operations from the Monad class.
| MonadFail IO Source | Since: base-4.9.0.0 |
Defined in Control.Monad.Fail | |
| MonadFix IO Source | Since: base-2.1 |
Defined in Control.Monad.Fix | |
| MonadIO IO Source | Since: base-4.9.0.0 |
Defined in Control.Monad.IO.Class | |
| Alternative IO Source | Since: base-4.9.0.0 |
| Applicative IO Source | Since: base-2.1 |
| Functor IO Source | Since: base-2.1 |
| Monad IO Source | Since: base-2.1 |
| MonadPlus IO Source | Since: base-4.9.0.0 |
| GHCiSandboxIO IO Source | Since: base-4.4.0.0 |
Defined in GHC.GHCi MethodsghciStepIO :: IO a -> IO a Source | |
| Monoid a => Monoid (IO a) Source | Since: base-4.9.0.0 |
| Semigroup a => Semigroup (IO a) Source | Since: base-4.10.0.0 |
| a ~ () => HPrintfType (IO a) Source | Since: base-4.7.0.0 |
Defined in Text.Printf | |
| a ~ () => PrintfType (IO a) Source | Since: base-4.7.0.0 |
Defined in Text.Printf | |
putChar :: Char -> IO () Source
Write a character to the standard output device (same as hPutChar stdout).
putStr :: String -> IO () Source
Write a string to the standard output device (same as hPutStr stdout).
putStrLn :: String -> IO () Source
The same as putStr, but adds a newline character.
print :: Show a => a -> IO () Source
The print function outputs a value of any printable type to the standard output device. Printable types are those that are instances of class Show; print converts values to strings for output using the show operation and adds a newline.
For example, a program to print the first 20 integers and their powers of 2 could be written as:
main = print ([(n, 2^n) | n <- [0..19]])
Read a character from the standard input device (same as hGetChar stdin).
Read a line from the standard input device (same as hGetLine stdin).
getContents :: IO String Source
The getContents operation returns all user input as a single string, which is read lazily as it is needed (same as hGetContents stdin).
interact :: (String -> String) -> IO () Source
The interact function takes a function of type String->String as its argument. The entire input from the standard input device is passed to this function as its argument, and the resulting string is output on the standard output device.
File and directory names are values of type String, whose precise meaning is operating system dependent. Files can be opened, yielding a handle which can then be used to operate on the contents of that file.
readFile :: FilePath -> IO String Source
The readFile function reads a file and returns the contents of the file as a string. The file is read lazily, on demand, as with getContents.
writeFile :: FilePath -> String -> IO () Source
The computation writeFile file str function writes the string str, to the file file.
appendFile :: FilePath -> String -> IO () Source
The computation appendFile file str function appends the string str, to the file file.
Note that writeFile and appendFile write a literal string to a file. To write a value of any printable type, as with print, use the show function to convert the value to a string first.
main = appendFile "squares" (show [(x,x*x) | x <- [0,0.1..2]])
readIO :: Read a => String -> IO a Source
The readIO function is similar to read except that it signals parse failure to the IO monad instead of terminating the program.
readLn :: Read a => IO a Source
The readLn function combines getLine and readIO.
type IOError = IOException Source
The Haskell 2010 type for exceptions in the IO monad. Any I/O operation may raise an IOException instead of returning a result. For a more general type of exception, including also those that arise in pure code, see Exception.
In Haskell 2010, this is an opaque type.
ioError :: IOError -> IO a Source
Raise an IOException in the IO monad.
userError :: String -> IOError Source
Construct an IOException value with a string describing the error. The fail method of the IO instance of the Monad class raises a userError, thus:
instance Monad IO where ... fail s = ioError (userError s)
class a ~# b => (a :: k) ~ (b :: k) infix 4 Source
Lifted, homogeneous equality. By lifted, we mean that it can be bogus (deferred type error). By homogeneous, the two types a and b must have the same kinds.
© The University of Glasgow and others
Licensed under a BSD-style license (see top of the page).
https://downloads.haskell.org/~ghc/9.4.2/docs/libraries/base-4.17.0.0/Prelude.html